How to set a cookie that is valid only for a specific domain, for example example.com, but not for its subdomains?

if I have a domain example.com, is there a way to make cookies valid only for that particular domain, and not for subdomains such as www.example.com?

I know that I can only install it www.example.com, but can it be without a subdomain?

+3
source share
2 answers

Cookies are identified by a combination of name, domain and path. Therefore, if properly installed, you can limit the scope to a specific domain / subdomain and path.

Wiki HTTP cookie
RFC2965

+1

, cookie, ";domain=example.com", "www.domain.com". ";domain=.example.com" www.

. , , .

-1

Source: https://habr.com/ru/post/1721768/


All Articles