admin管理员组

文章数量:1302867

sessionStorage is supposed to be cleared after the browser is restarted, according to MDN:

data stored in sessionStorage gets cleared when the page session ends

I restart and restart Firefox 59 and Chrome 65 — and nothing, sessionStorage's data is still there. Why would that be?

sessionStorage is supposed to be cleared after the browser is restarted, according to MDN:

data stored in sessionStorage gets cleared when the page session ends

I restart and restart Firefox 59 and Chrome 65 — and nothing, sessionStorage's data is still there. Why would that be?

Share Improve this question edited Jan 22, 2018 at 6:14 T.J. Crowder 1.1m199 gold badges2k silver badges1.9k bronze badges asked Jan 21, 2018 at 14:39 TotalAMDTotalAMD 1,0161 gold badge11 silver badges21 bronze badges 16
  • 3 Like select, Firefox and Chrome are not broken. ("Not broken" background: pragprog./the-pragmatic-programmer/extracts/tips). Show us the code that you think is demonstrating that session storage is not getting cleared, and we'll tell you what's wrong with it. (Edit: Just tested to be absolutely sure, and both Chrome and Firefox dropped the values I put in session storage when they were expected to -- of course.) – T.J. Crowder Commented Jan 21, 2018 at 14:41
  • 2 Testet in Firefox, using the option "Restore last session" restores sessionStorage. – Roland Starke Commented Jan 21, 2018 at 14:56
  • 1 @T.J.Crowder :) I bet that this is the problem OP is having :D. (idk i don't use sync, but maybe if you do, your sessions never end) – Roland Starke Commented Jan 21, 2018 at 15:09
  • 1 @totalamd: It being visible if you dive into the browser's list of what it has stored is not the same as it not expiring. It's entirely within spec if Firefox doesn't clear that data until you next request it and it says "Oh, this data is obsolete -- we'll throw it out and start fresh." Or if it doesn't even do that. So long as sessionStorage.getItem("test") doesn't return "qwe" when you call it in a fresh session, it's in-spec. So again: Post the code that you think demonstrates the problem. – T.J. Crowder Commented Jan 21, 2018 at 16:23
  • 1 @T.J.Crowder Created new Firefox profile, turned out show tabs&windows from last time saves sessionStorage. – TotalAMD Commented Jan 21, 2018 at 22:41
 |  Show 11 more ments

1 Answer 1

Reset to default 11

For those who are wondering and here. If user has selected to continue where he left option of similar feature in any browser. sessionStorage will be saved by the browser in between the restarts of the browser.

We had to get our requirements changed as because of this. Hope it will be helpful for some

本文标签: javascriptsessionStorage doesn39t clear after browser restartStack Overflow