cmp-cc / vue-cookies

A simple Vue.js plugin for handling browser cookies
MIT License
408 stars 70 forks source link

Can't set domain by vue-cookies #78

Closed tangxife closed 2 years ago

tangxife commented 2 years ago

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'

cmp-cc commented 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.

For example

sub-domain add cookie to main-domain :

tangxife commented 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.

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