By LUKE MCGOVERN
Published: August 14, 2008
CakePHP's handling of session variables appears to be very weird at first. Some of the confusion is caused when $_SESSION variables are added within code in the app/webroot and they don't appear in any of the views, models or controllers. The reverse case is also true where session variables set by the CakePHP app cannot be accessed by the code in the app/webroot directory. Sounds like shenanigans but in your core.php file you should find something like...
Configure::write('Session.cookie', 'CAKEPHP');
If you change it to...
Configure::write('Session.cookie', 'PHPSESSID');
you should be back to basics and your $_SESSION vars will be shared across both areas. If you are still having problems look at your cookies on the site in question and check whether there are multiple sessions being maintained. In most instances you will only want to maintain one session.
Note: the session cookie name just needs to correspond to the session name in your php.ini file - the default is PHPSESSID.
Add Comment