question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deleting cookies: All paths & domains

See original GitHub issue

Whe I try to delete a cookie by simple delete method, it does not work. I think it requires to the path & domain also.

this.cookieService.delete("auth_token");

thus, I need to write:

this.cookieService.delete("auth_token", "/", "quizcv.com");
this.cookieService.delete("auth_token", "/", "www.quizcv.com");
this.cookieService.delete("auth_token", "/", "localhost");

which is very uncomfortable. Moreover, there are some combinations with different paths.

How can I delete all cookies, whatever the path or domain is?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

6reactions
jeeva-nikamcommented, Mar 1, 2018

No need to add domain it worked for me like this… this.cookieService.delete(‘myCookie’, ’ / ');

2reactions
paroecommented, Nov 3, 2018

The browser (and therefore the cookie-service) simply just have no way of knowing the paths and domains of the set cookies. For security reasons, they can only access the cookies of the current path and domain.

Here you can find a good explanation of the issue:

For security, you’re not allowed to edit (or delete) a cookie on another site. Since there’s no guarantee that you own both foo.domain.com and bar.domain.com, you won’t be allowed to edit the cookies of foo.domain.com from bar.domain.com and vice versa.

The only thing you can do is to take an educated guess, like in this attempt.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - how to delete all cookies of different path under a domain
getCookies(); gets all the Cookies that are sent by the browser to the Server. Check if the cookies you expect are getting returned,...
Read more >
cookies.remove() - Mozilla - MDN Web Docs
The remove() method of the cookies API deletes a cookie, given its name and URL. The call succeeds only if you include the...
Read more >
setcookie - Manual - PHP
The path on the server in which the cookie will be available on. ... If you want to delete all cookies on your...
Read more >
JavaScript Cookies - w3resource
For each domain and path, you can store upto 20 cookies. ... If a page www.w3resource.com/javascript/ sets a cookie then all the pages...
Read more >
Unable to delete cookie "_mkto_trk" from parent domain
document.cookie = "_mkto_trk=; path=/; domain=.example.com;expires=Thu, ... example.com and all subdomains — you could delete it either with
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found