Take the 2-minute tour ×

I am having two CakePHP application working on the same domain.

They are located at localhost:8080/wishlist and localhost:8080/lighthouse.

"Wishlist" and "lighthouse" are each separate CakePHP applications.

The login page is at localhost:8080/lighthouse, and I want the session generated by the lighthouse application to be used in the wishlist application.

The directory structure is


I have edited the core.php file for each application. I am using the same session cookie name and the same security sale but I am not able to get the session on the wishlist application.

How can I share a session in between my two applications?

share|improve this question
As a side note, your directory structure could be /htdocs/wishlist/config, /htdocs/lighthouse/config, /htdocs/cake, /htdocs/vendors. By convention, this would allow both applications to share the same cake installation and global vendors directory without any manual configuration, and it would respond to the same URLs. A common mistake is thinking that the app directories cannot be renamed, which isn't the case. :) –  deizel Jun 8 '10 at 13:15

2 Answers 2

Firstly, install Firefox, Firebug and Firecookie. This will add a 'Cookies' tab to Firebug making it simple to inspect your cookies.

Cookies consist of multiple parts: name, value, domain, path, expires, etc. You are most interested in the 'path' part of the cookie here I believe.

By default CakePHP will restrict the path of each cookie to the subdirectory of your app. For example, when you visit /wishlist, a cookie will be created but it will be restricted to the /wishlist subdirectory. When you then go to /lighthouse the previous cookie won't apply, so thinking that you have no cookie/session, a new one is created that is restricted to the /lighthouse subdirectory.

You need to change the path of created cookies to / so they persist across all subdirectories. This should be as easy as adding ini_set('session.cookie_path', '/'); to both application's app/config/bootstrap.php files.

share|improve this answer
Thanks a lot the solution worked for me. I have posted the details here amityadav.name/… –  Amit Yadav Jun 9 '10 at 10:38

You should look at developing each one as a plugin or developing them in the same app. I am not sure why you would want to develop two seperate apps when they are sharing a login screen.

share|improve this answer
Its the result of a bad programming that the earlier programmer did. These were two separate apps and now they want them to merge. –  Amit Yadav Jun 9 '10 at 4:16

Your Answer


