9

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)

Maurizio Pozzobon
  • 3,044
  • 7
  • 34
  • 44

1 Answers1

4

You can only share cookies between a domain and its own subdomains. For example:

  • a cookie defined for the domain example.com can be accessed by www.example.com and foo.bar.example.com
  • a cookie defined for the domain www.example.com can be accessed by foo.www.example.com but not by bar.example.com
Efran Cobisi
  • 6,138
  • 22
  • 22
  • to be more accurate, a cookie for `.example.com` can be accessed by its subdomains. notice the leading period – Joe B Dec 05 '14 at 20:44
  • But how do I PREVENT `foo.example.com` from reading `example.com`'s cookies? I need the subdomain to be completely separate. I don't want `example.com` reading `foo.example.com`'s cookies either. – Buttle Butkus Jun 26 '15 at 20:27