Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

COOKIES: .somedomain.com and somedomain.com

1:19 am on May 5, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:July 11, 2008
posts: 88
votes: 0

What is the difference between cookies stored for
.example.com and example.com

(NOTICE the leading dot)

Is this just a JS vs PHP difference or is there more to it?

[edited by: incrediBILL at 2:01 am (utc) on May 5, 2010]
[edit reason] Only use EXAMPLE.COM for sample domain names [/edit]

9:21 am on July 8, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0

Essentially the same AFAIK, the leading dot is not strictly required. The domain is tail-matched with the domain in the URL. However, it apparently makes it compatible with more browsers.

Having said that, however, the HTTP Cookie Specification [curl.haxx.se] does state...
...domains must have at least two (2) or three (3) periods in them to prevent domains of the form: ".com", ".edu", and "va.us". Any domain that fails within one of the seven special top level domains listed below only require two periods. Any other domain requires at least three. The seven special top level domains are: "COM", "EDU", "NET", "ORG", "GOV", "MIL", and "INT".

Which would imply that you need to specify ".example.com" (with a leading dot)?

Cookies are part of the HTTP protocol, so it shouldn't matter whether you are using JS or PHP in this respect.