Reputation: 506
I have extremely weird behaviour in Chrome: Version 61.0.3163.79 (Official Build) (64-bit).
I keep a token in localStorage and I cannot remove it permanently. Now matter whether I do it programmatically by localStorage.removeItem('token')
or by Chrome tools in the application tab, this token keeps coming back. After removing the token, when I refresh the page, token is not there, but once I close this tab and open a new one for my application, this token is resurrected!
Also, when I have multiple tabs opened, when I refresh pages, some tabs see this token, some not, and it shouldn't be like this as localStorage should be global for all tabs.
I have no idea what this is, a new Chrome bug?
Upvotes: 8
Views: 2899
Reputation: 341
I found that when I delete a key/value, it doesn't appear to work. If I "Refresh" by right-clicking in the Local Storage the value is gone.
Prior to the Refresh, if is entered localStorage.getItem("key") it returned null, so, the value is deleted, but, still just showing.
Seems to be just a refresh bug in Chrome.
Upvotes: 0
Reputation: 1
I came across with the same problem today with FedEx webpage that is not loading the login page. seems that main page is sharing a token betweeen main page and login page, and even if I erase the specific site cookies manually and all the related information loaded inside the application (cache, cookies, IndexedDB, etc.), when I reload the website, the same information is loaded again, so the way to fix it was to clear all the navigation data of chrome (only cookies and files).
I also tried with Matt Terski's workaround but id didn't work. So I believe it is an application error, or perhaps chrome have other data loaded globally on the navigator and it uses that same information for specific websites.
This is the second time it happens and I had to fix it quick so I didn't have much time to troubleshoot. Maybe it is Chrome version.
Upvotes: 0
Reputation: 4456
In 2022 it seems still be the case, at least I've failed to remove an item with the mouse right click → context menu → delete
But I've managed to do it via a double click on the key value, which puts you sort of into an edit mode, so that one can just then press Backspace and the key is removed.
Upvotes: 4
Reputation: 951
I noticed the same behavior and verified that it did not work this way in Chrome version 60.
It looks like a bug in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=765524
As a workaround, I changed
localStorage.removeItem('token')
to
localStorage.setItem('token', '')
and that seems to give me the expected behavior (i.e. logout works).
Upvotes: 9