Monthly Archives: June 2011

CakePHP Session Cookie Path

In CakePHP I needed a way to have an app at “/app” but be able to share session data with another app. The easiest way is to set the Session Cookie path to “/”. The problem is that Cake sets the session cookie to the base path–in this case “/app”. There is no setting to override this behavior. But I discovered that if you start the session yourself, you can specify “/”. Here is the code.

require_once(ROOT . '/cake/libs/controller/components/session.php');
Configure::write('Session.start', true);
$s = new SessionComponent('/');