Few days back i was working on two separate CakePHP applications, suddenly there was a need to maintain session between these two separate apps working on the same domain. Let me explain a bit more.

Image via Wikipedia

I was having two apps (i)wishlist (ii) lighthouse

These are two separate apps under the root folder having the directory structure as:
/config ….

By default the sessions are created relative to the apps directory, and this was the problem i was dealing with, not a big thing but i spent a lot of time figuring this, but for you its will work like a charm.

Steps that i follow to make the two apps share sessions between them.
1. Edit “core.php” for wishlist and the lighthouse and add the line
ini_set(‘session.cookie_path’, “/”);
This is to direct the CakePHP app to create the session on the root

2. The Session.cookie name should be same for the two apps

3. The Session.salt should be same for the two apps

4. Security.level should be low in both the apps

This is it what is required. Let me know if you are still stuck with the things, happy coding.


6 comments on “CakePHP Sharing sessions between apps on the same domain

  • Hello Amit
    I am facing a same problem on my local host to be setup with two cakephp applications, can I get your mobile number so that we can discuss.
    Mine is 9325660481.

  • I drop a leave a response each time I appreciate a article on a site or I have something
    to contribute to the discussion. It is triggered by the passion communicated in the post I looked at.
    And after this article CakePHP Sharing sessions between apps on the same domain | Amit Yadav.
    I was moved enough to drop a leave a responsea response ;-) I actually do have a couple of questions for you if it’s okay. Could it be simply me or do a few of the responses come across like written by brain dead visitors? :-P And, if you are writing on additional online sites, I’d
    like to follow everything new you have to post. Could you
    make a list every one of all your communal sites like your linkedin profile, Facebook page or twitter feed?

Leave a Reply

Your email address will not be published. Required fields are marked *