microcipcip / cookie-universal

Universal cookie plugin, perfect for SSR
525 stars 39 forks source link

no opts domain for get method? #84

Closed am05mhz closed 4 years ago

am05mhz commented 4 years ago

there is domain opts for set and remove, but why not on get?

for example i set a cookie 'abcd' with '.example.com' domain, with value 123 then i set another cookie with same name for domain sub.example.com and value 987

how do i get the first or second cookie?

daniluk4000 commented 3 years ago

@am05mhz how did you solve this?

am05mhz commented 3 years ago

@daniluk4000 its a bad practice to use same cookie name on main domain .domain.tld and subdomain sub.domain.tld, if you want to use same name, you need to set the cookie at main domain level, even when you are on subdomain, this way you can access the cookie from any subdomain

get will follow browser's value, depends on current url on which subdomain, that is why no domain opts on get

Surt commented 2 years ago

@daniluk4000 its a bad practice to use same cookie name on main domain .domain.tld and subdomain sub.domain.tld, if you want to use same name, you need to set the cookie at main domain level, even when you are on subdomain, this way you can access the cookie from any subdomain

get will follow browser's value, depends on current url on which subdomain, that is why no domain opts on get

Did you follow those rules? right now I'm setting all the cookies as the "domain.com" but I want to access them from the "subdomain.domain.com" I also try to set the cookies domain with ".domain.com" with no luck I can't access them from the subdomain.

I have no much control on the cookies because they are set during proxy calls