Closed tangxife closed 2 years ago
RFC6265: The user agent will reject cookies unless the Domain attribute specifies a scope for the cookie that would include the origin server.
sub-domain add cookie to main-domain :
$cookies.set('key',value,expire); // only sub.domain.com are readable
$cookies.set('key',value,expire,'/','domain.com'); // domain.com and *.domain.com are readable
$cookies.set('key',value,expire,'/','sub.domain.com'); // *.domain.com are readable
$cookies.set('key',value,expire,'/','sub.sub.domain.com'); // invalid, no noe
$cookies.set('key',value,expire,'/','xxxx.com'); // invalid, from different doamin
RFC6265: The user agent will reject cookies unless the Domain attribute specifies a scope for the cookie that would include the origin server.
For example
sub-domain add cookie to main-domain :
- current path: sub.domain.com
$cookies.set('key',value,expire); // only sub.domain.com are readable $cookies.set('key',value,expire,'/','domain.com'); // domain.com and *.domain.com are readable $cookies.set('key',value,expire,'/','sub.domain.com'); // *.domain.com are readable $cookies.set('key',value,expire,'/','sub.sub.domain.com'); // invalid, no noe $cookies.set('key',value,expire,'/','xxxx.com'); // invalid, from different doamin
thsnks! I got you
I set cookie like this:
cookies.set("user", "ss", "Wed, 05 Aug 2025 23:00:00 UTC", "/", ".ccc.com");
can't!this:
cookies.set("user", "ss", "Wed, 05 Aug 2025 23:00:00 UTC", "/");
can! but domain is not change,always 'localhost'