May 15, 2008

How to set the session path for CakePHP sessions

Filed under: Programming — Tags: , , — Finster @ 12:10 pm

I had an issue where my CakePHP app (which was part of a larger webapp) was setting its own cookie_path for ‘/cakeapp’, which was the location of Cake. Meanwhile, the session for the general app, with cookie_path at ‘/’ was also setting up its own session. So, I needed Cake to use ‘/’ for its session.cookie_path instead of defaulting to the Cake app’s path.

The simplest way to do this for me was to set Session.start to false in core.php. Then, I added a $this->Session->activate(’/'); to my app_controller.php in a beforeFilter() function. Now, the Cake app is using ‘/’ for it’s session.cookie_path.

h/t AD7six in #cakephp for showing me this.

1 Comment »

  1. GREAT!! thank you!

    I looked for this about 5 hours!

    Comment by inniskun — June 4, 2008 @ 2:00 am

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress