Closed jamilalisgandarov closed 7 years ago
👍 +1
First of all, I think a DELETE
request would be more appropriate for logging out.
Are you sure that it is always accessing the content of if
? My guess would be, when there's something wrong with the api and data status is something other than that 200, it simply doesn't reach there. Until you provide more information than "some cases", I can't tell anything more.
@salemdar I get status 200, there is not any problem about API, because this._router.navigate(['/login']);
was working fine, so it reaches there. I think I have fixed it, I was using providers:[CookieService] in my child module, perhaps problem was related with that. It has been fixed after deleting it from the child module.
Cool. But I strongly recommend migrating to ngx-cookie.
Actually I have migrated it (got same problem). It has been fixed) Thanks
Im still having this issue. I have an auth service that is in my core module, and im in the same boat as you @jamilalisgandarov where the route is hit, it can read the cookies, however when I try to delete they are still remain.
// TODO:: need to clear cookies from browser to clear auth token on logout
public logout() {
this.sessionStorage.clear();
//this outputs the cookie like its supposed to
console.log('auth before delete token cookie::', this.cookies.get('token'));
this.cookies.removeAll();
//cookie still remains
console.log('auth token cookie::', this.cookies.get('token'));
this.setLoggedIn(false);
}
Also, this is for both ngx-cookie and angular2-cookie, as ive tried them both
I have the same issue, remove
or removeAll
don't remove a thing, cookie is still there
This may be relevant: https://www.owasp.org/index.php/HttpOnly#Browsers_Supporting_HttpOnly
I'm using ngx-cookie@1.0.1 and angular@4.4.6.
I used EditThisCookie extension in google chrome to add Cookies to my application as a session (without HttpOnly) as shown in the below screenshot. Still, remove or removeAll is not working for me.
I have used removeAll in my logout method of my Login service and have used a link to invoke this method.
Has anyone found a solution for this. Any help is much appreciated.
If that be of any help for someone else, I had the same problem. For my part, it was due to the domain level:
My service was at directory.ob.forgerock.financial but my cookie was .ob.forgerock.financial
I had to explicitly do Cookie.deleteAll("/", ".forgerock.financial");
to make it works.
Hi. I am using cookies for authentication, but I have a problem with removing cookies when user log out. As I see it doesn't remove cookies in some cases, can't find what's wrong with it. I share my user login, logout functions below. Is there anything wrong?
ng version
USER LOGIN
USER LOGOUT