Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting cookies: All paths & domains #2

Closed
mustafaekim opened this issue Aug 24, 2017 · 6 comments
Closed

Deleting cookies: All paths & domains #2

mustafaekim opened this issue Aug 24, 2017 · 6 comments

Comments

@mustafaekim
Copy link

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?

@mustafaekim
Copy link
Author

Note: If get method would not return a string but an object with path & domain of the cookie, I would be able to delete all the cookies because I would know their path & domains

@roelzkie15
Copy link

Had the same issue deleting cookies with deleteAll() method it doesn't work either

@jeeva-nikam
Copy link

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

@paroe
Copy link

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

@sahajrajmalla
Copy link

I have same problem!

@rajibhalder
Copy link

I have the same problem as my frontend server hosted on abc.com but api server hosted on xyz.com server. When log out, I want to delete all cookies (e.g accessToken, JSESSIONID) of xyz.com also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants