Hacker News new | ask | show | jobs
by zrail 3664 days ago
Cookies are scoped to a domain name and all subdomains under that domain name. For example, if you set a cookie on `ycombinator.com` that cookie will be presented to `news.ycombinator.com` as well.

Using `www.example.com` as your cookied domain allows you to avoid sending your cookies to `cdn.example.com`, shaving off a few bytes of incoming bandwidth per request. Whereas if you use `example.com` as your cookied domain, those cookies will be passed to `cdn.example.com`. To avoid that, you'd have to set up your CDN on a completely different domain like `examplecdn.com`.

1 comments

Another nice explanation on this!