New core helper: SessionHelper

Published on and tagged with cakephp  helper

In the latest version from trunk (1.1.7.3346), a new helper has been introduced: SessionHelper. Up to now it was rather cumbersome to work with session data in the view:

$this->controller->Session->read('User.name');

With the new SessionHelper the code snippet from above looks like:

$session->read('User.name');

The SessionHelper is automatically available in the view, i.e. you do not have to add it to the helpers array in the controller. It provides the following functions:

  • read($name = null)
  • check($name)
  • error()
  • flash($key = ‘flash’)
  • valid()

5 comments baked

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License