You are in a maze of twisty passages, all alike.
RSS icon Email icon Home icon
  • How to set the session path for CakePHP sessions

    Posted on May 15th, 2008 Finster 3 comments

    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.


    3 responses to “How to set the session path for CakePHP sessions” RSS icon

    • GREAT!! thank you!

      I looked for this about 5 hours!

    • Great deal,
      Even you can set session.cookie_path in session.php in cake/libs/ in function __initSession() and in case ‘php’. I have blocked this line and getting session values.

    • this does work, but not for authentication. Do you know how to make it work with authentication?

    Leave a reply