I'm trying to clear all the info my app is saving in the browser, whether it's in sessionStorage, localStorage or cookies.
I've added this small method to do so, and it get called in the ngOnInit
of one of my components:
export class SomeComponent implements OnInit {
constructor(private cookieService: CookieService) {}
ngOnInit(): void {
this.clearAppData();
}
private clearAppData(): void {
sessionStorage.clear();
localStorage.clear();
this.cookieService.deleteAll();
}
sessionStorage
and localStorage
seems to be cleared, yet I can see that the cookies are not.
I need to manually clear the cookies through the browser.
Moreover, sometimes I see that the cookie is saved under the root path, and sometimes I see it under the relative root path. I'm not sure what is the cause of this, and as sometimes it sends the wrong cookie, I would like to clear everything before getting a new one.
Any suggestions what am I doing wrong? Thanks!