1

Working on a Cookie Manager chrome extension, I added below 4 cookies one by one using chrome.cookies.set method. All the 4 cookies have the same name, but different domain/path combination.

enter image description here

Now, if I remove one cookie using chrome.cookies.remove method, it is also deleting some other cookies depending on domain and path. For example, if I delete first cookie which have domain as "stackoverflow.com" and path as "/questions", it is deleting the remaining 3 cookies as well which have the same name.

How can I distinguish between the domains "stackoverflow.com" and ".stackoverflow.com" in chrome.cookies.remove method?

Why deleting cookies of same domain, same name but longer path also deleting the cookies of same domain, same name but shorter path?

How can I achieve the behavior of deleting any one cookie does not remove any of the other 3 cookies?

I am using below method to construct url when using chrome.cookies.remove method:

function buildRemoveCookieUrl(cookie) {
   return `http${cookie.secure ? 's' : ''}://${cookie.domain}${cookie.path}`;
}

Thanks,

CodeZila
  • 919
  • 2
  • 14
  • 31

0 Answers0