Problem in maintaining session between two different domains on a website done in CakePHP

cakephp, php, session

Solution

I'm not sure I completely understand, but I'm gonna try. I think this is about a PHP setting called `session.cookie_domain`.

Assuming your websites have the following URLs:

- http://www.example.org/

- http://fr.example.org/

- http://de.example.org/

The setting you want is: `.example.org`.

You can adjust this in `php.ini`, a `.htaccess` file or even in PHP itself:

<?php ini_set('session.cookie_domain', '.example.org'); ?>

If your websites run on two completely different domains, e.g.:

- http://example1.org/

- http://example2.org/

... then there is no way to share the cookie between these two different domains.

Problem

Well as I have posted earlier too...I have created a site in two languages. One with URL `www.mainDomain.com` (English) and other with `www.fr.subDomain.com` (French). Both are done in CakePHP,in french I have just changed the views of it to French. But the problem is, when anybody login's in English version and then switches to the French version, the session doesn't recognizes it and ask for login again. It has become to be the biggest bug in the Web application which I have done till far. For that, as Swanny told me to go through a link and I did it on my application as it was said on the link.Apparently,it worked for login which shared session between two domains(main domain and it's subdomain). But when I checked it thoroughly, I recognized that both the sites are throwing the latest NEWS from Database, both data are different. Just to check if I was wrong I changed the some save variable to database in session array. But now it refused to remember anything (session). Could anyone suggest me what could be problem with this and how can I resolve this...??? Thanks in advance

Original source