Set session cookies for specific subdomains

I have a website with several subdomains that use a unique PHP session cookie to identify each user. I did this by simply adding session.cookie_domain = '.mydomain.com' , however I wonder if it is possible to specify more than one subdomain, so that the cookie will only be sent, for example, www.mydomain.com and user.mydomain.com , but will not be at images.mydomain.com . Is it possible?

+6
source share
2 answers

No, these must be two separate cookies.

You will need to create a subdomain like sub.mydomain.com , have hosts like www.sub.mydomain.com etc., and set cookies for .sub.mydomain.com if you want to isolate cookies like this way ...

+2
source

for future users, in fact you can just rename the cookie id and you may have a specific cookie for this subdomain

-1
source

Source: https://habr.com/ru/post/900885/


All Articles