Software Development > CakePHP Session Webroot Issues

CakePHP Session Webroot Issues

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.

Comments

1. SHADAB SHAIKH on April 16, 2009

Great Help..!! This is really very nice tip.. :)

Any Comments?

SVN and Dreamweaver CS4 Integration

By LUKE MCGOVERN
Published: June 30, 2009

Adobe Dreamweaver CS4 now comes with SVN integration. It's their one big feature for developers in this version. To bad it's completely useless.

Solving TortoiseSVN, SVN+SSH, Putty and Plink Chaos

By LUKE MCGOVERN
Published: December 8, 2008

Trouble shooting guide for setting up TortoiseSVN with the SVN+SSH scheme. Understanding Plink can help the diagnosis.