Can anybody give me a further explanation about the isDomain
property of the nsICookie
interface?
If .isDomain
is true, the cookie is to be used for the whole domain (host + all subdomains), otherwise it is only to be used for a specific host.
When setting the cookie and specifying a domain=
value with a leading .
, the cookie becomes a domain cookie. See the document.cookie
documentation.
E.g.
domain=.example.org
will be a domain cookie (.isDomain == true
) and will be used for example.org
and all sub-domains, such as www.example.org
.domain=example.org
will not be a domain cookie (.isDomain == false
) and will only be used for example.org
, but not for subdomains.domain=www.example.org
will not be a domain cookie (.isDomain == false
) and will only be used for www.example.org
, but not for subdomains.It is implemented simply as:
inline bool IsDomain() const { return /* const char* */ *mHost == '.'; }
meaning: Return true
if the first char of the string is a .
, else return false
.