es-cookie icon indicating copy to clipboard operation
es-cookie copied to clipboard

Cookie not removed with same attributes

Open ferdoran opened this issue 6 years ago • 2 comments

When I set a cookie with domain example.com from foo.example.com the domain of the cookie is being set to .example.com.

Cookies.set('mycookie', 'myvalue', {domain: 'example.com'} will result in: "mycookie=myvalue; Domain=.example.com; Path=/"

However If I want to remove it with the same attributes, the cookie is not removed:

Cookies.remove('mycookie', {domain: 'example.com'}

Prepending a period to the domain fixed it for me:

Cookies.remove('mycookie', {domain: '.example.com'}

ferdoran avatar Jul 02 '19 08:07 ferdoran

I don't think this is a bug, but expected behavior from browsers. When setting a cookie that should be accessible from both a domain and its subdomains, the domain is supposed to have a period prepended. See https://stackoverflow.com/questions/3089199/can-subdomain-example-com-set-a-cookie-that-can-be-read-by-example-com.

theodorejb avatar Jul 05 '19 15:07 theodorejb

Sure

carlosdavid0 avatar Sep 05 '22 12:09 carlosdavid0