What is the difference between setting a cookie domain to www.site.com vs .www.site.com when I want to limit a cookie to the www subdomain?

Simply if you set a cookie to whole domain, it will apply to this domain and all its subdomains.
When you set cookie to a specific subdomain it will apply to this specific subdomain only; meaning it will not cover root-level domain nor any other subdomain withunder root domain.

The one with dot means set cookie to whole domain including subdomains
Without dot means set cookie to the specific (sub)domain only.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.