I have been trying to find out a way to share cookies across multiple subdomains.
Setting the cookie like:
setcookie('token', base64_encode(serialize($token)), time()+10800, '/', '.mydomain.com');
does exactly that. But there is a slight problem here. This will share the cookie across all subdomains.
My problem is that I have other environments (Dev and test) set up on 2 subdomains. I am looking for a way to share cookies across "Selective" subdomains. i.e. share across some subdomains, and not share amongst others. I am not sure if anything like this exists.
Any help is appreciated. Thanks.
After thinking and researching a lot about it and reading all the valuable comments posted above, I guess there is no straightforward solution to this.
I could have gone with the solution provided by Adrien Hingert, but that would mean an additional check everytime a user comes in.
I guess I am left with no other option but to move my dev and test environments to another domain.
Thanks a lot all of you guys for your thoughts.