By default, cookies are limited to the URL node on which they were set. Thus, the cookie set on " http://example.com/foo.html can be seen on other pages on" example.com ", but not on other sites - not even subdomains.
You can specify a domain attribute for the cookie, which can make it visible to more hosts. This domain attribute must begin with a period and must be the suffix of the host name of the cookie page. Cookies set with a domain attribute are (potentially) visible to pages on sites for which the domain attribute is a suffix. Therefore, if the cookie domain attribute is ".example.com", it will be displayed on "www.example.com", "forums.example.com", "foo.bar.example.com", but not "example.com "". Therefore, if you run part of your site with "example.com", you cannot make cookies visible to subdomains, but if you always use subdomains, you can make cookies that all subdomains can see.
You can find a very detailed, but somewhat hard to read explanation of this in RFC2965 . I also found a websiteGear article that has a pretty clear explanation.
source share