I'm in the process of adding a second site to a Craft installation using custom locales. The two sites will be accessed on different sub-domains, e.g. site1.domain.com
and site2.domain.com
.
I need to ensure that logged in users can access both sites.
When I developed the first site, I didn't know that there would be a requirement to add a second site at a later date, so I set the defaultCookieDomain
config setting to site1.domain.com
.
Now that I am developing the second site, I have changed this config setting to .domain.com
, which should mean that sessions are recognised across both sites.
However, in my testing, due to the fact that cookies still exist for site1.domain.com
, Craft is not recognising that I am logged in when I visit site2.domain.com
.
If I delete the cookies from my browser and log into either site, Craft correctly recognises that I am logged into both sites.
This is fine for me to do, if a little annoying. However there are over 4000 registered users of site1.domain.com
and I don't want to have to expect them to delete their cookies to enable them to access both sites. Is there something I can do to get Craft to avoid this problem by automatically delete their existing cookies and regenerate ones for .domain.com
with no user intervention?