Is there any way to set a cookie that is not readable on subdomains? In other words, have the cookie available on domain.com, but not www.domain.com or xyz.domain.com.
//this is what i'm "intending"...
setcookie($name,$value,$expires,'/','domain.com');
//however, this is how it behaves:
setcookie($name,$value,$expires,'/','.domain.com');
The reasoning: I’m setting up a static CDN on a subdomain and don’t want the user session cookies going back and forth for every image, css file, js file, etc.
…do I have to fall back to using www.domain.com for my site? Are there any workarounds?
Apparently, having a cookie on “domain.com” that will match “*.domain.com” is expected behaviour.
For instance : PERSISTENT CLIENT STATE HTTP COOKIES state (some emphasis mine) :
So, you’ll either have to :
www.domain.com” for your site.anotherdomain.com“)