I'm trying to share a cookie between www.example.com and admin.other.example.com I've being able to make it work with other.example.com, but there's no way to access the sub-sub-domain
Edit: I handle subdomains by defining the cookie domain as .example.com (note the first dot)
To share a cookie between domains, you will need two domains, for example myserver.com and slave.com . One of the domains will issue the cookies and the other domain will ask the first domain what cookie should be issued to the client.
To share cookies across subdomains, you can simply create cookies with the domain directive set to the parent domain, in this case, example.com, rather than either of the specific subdomains.
Cookies are only accessible to a single domain that they are set to. I believe if you are using two sub-domains on the same domain it would be possible to share the cookies, however the browser doesn't send cookies set on one domain to any others. Edit: You also want to avoid storing large amounts of data in a cookie.
The origin domain of a cookie is the domain of the originating request. If the origin domain is an IP, the cookie's domain attribute must not be set. If a cookie's domain attribute is not set, the cookie is only applicable to its origin domain.
You can only share cookies between a domain and its own subdomains. For example:
example.com
can be accessed by www.example.com
and foo.bar.example.com
www.example.com
can be accessed by foo.www.example.com
but not by bar.example.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With