Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set session cookies for specific subdomains

I have a website with multiple subdomains, which share a unique PHP session cookie to identify each user. I did this by simply adding session.cookie_domain = '.mydomain.com', however I'm wondering if it's possible to specify more than one subdomain, so that cookies will only get sent to, for example, www.mydomain.com and user.mydomain.com but won't in images.mydomain.com. Would this be possible?

like image 425
Ruben Avatar asked Nov 06 '11 14:11

Ruben


1 Answers

No, those would have to be 2 separate cookies.

You would have to create a sub-domain like sub.mydomain.com, have hosts like www.sub.mydomain.com etc., and set cookies for .sub.mydomain.com if you wanted to isolate cookies in that way...

like image 58
e.dan Avatar answered Sep 28 '22 11:09

e.dan