Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wearethefoos/822724 to your computer and use it in GitHub Desktop.
Save wearethefoos/822724 to your computer and use it in GitHub Desktop.
A question a lot of people seem to ask about the CakePHP Session Component is how to access it from e.g. a Model. There are quite a few suggestions to be found on Google, but none of them strike me as very elegant. I came up with this one, and it works fr
App::import('Core', 'Controller');
App::import('Component', 'Session');
$Controller = new Controller();
$Session = new SessionComponent();
$Session->startup($Controller);
$Session->read('Auth.User');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment