Why is sessionStorage not clear when closing browser or tab like chrome?

%3CLINGO-SUB%20id%3D%22lingo-sub-3495537%22%20slang%3D%22en-US%22%3EWhy%20is%20sessionStorage%20not%20clear%20when%20closing%20browser%20or%20tab%20like%20chrome%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3495537%22%20slang%3D%22en-US%22%3E%3CP%3EsessionStorage%20is%20supposed%20to%20be%20cleared%20when%20someone%20close%20browser%2C%20but%20it%20seems%20not%20working%20that%20way.%26nbsp%3B%3C%2FP%3E%3CP%3Ehow%20to%20reproduce%3A%3C%2FP%3E%3CP%20data-unlink%3D%22true%22%3E1.%20open%20browser%20new%20tab%2C%20goto%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.microsoft.com%2F%3C%2FA%3E%26nbsp%3B%3B%3C%2FP%3E%3CP%20data-unlink%3D%22true%22%3E2.%20open%20devtools%20and%20set%20sessionStorage%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EsessionStorage.setItem('mykey'%2C%20'somevalue')%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%20data-unlink%3D%22true%22%3E3.%20close%20browser%20and%20reopen%2C%20in%20my%20browser%20preferences%2C%20it%20will%20open%20last%20opened%20tabs%3C%2FP%3E%3CP%20data-unlink%3D%22true%22%3E4.%20open%20devtools%20and%20check%20sessionStorage%20%2C%20and%20you'll%20see%20the%20value%20still%20exists.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3EsessionStorage.getItem('mykey')%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Esome%20steps%20for%20chrome%2C%20and%20chrome%20sessionStorage%20is%20auto%20clear.%20Is%20there%20something%20wrong%3F%20or%20this%20is%20by%20design%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eby%20the%20way%2C%20if%20you%20close%20tab%20instead%20of%20close%20entire%20browser%2C%20and%20undo%20tab%20close%20right%20after%20that%2C%20the%20sessionStorage%20is%20keep%20without%20clear%2C%20which%20is%20user-friendly%20and%20is%20consistent%20between%20msedge%20and%20chrome%2C%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

sessionStorage is supposed to be cleared when someone close browser, but it seems not working that way. 

how to reproduce:

1. open browser new tab, goto https://www.microsoft.com/ ;

2. open devtools and set sessionStorage 

 

sessionStorage.setItem('mykey', 'somevalue')

 

3. close browser and reopen, in my browser preferences, it will open last opened tabs

4. open devtools and check sessionStorage , and you'll see the value still exists.

 

sessionStorage.getItem('mykey')

 

 

some steps for chrome, and chrome sessionStorage is auto clear. Is there something wrong? or this is by design?

 

by the way, if you close tab instead of close entire browser, and undo tab close right after that, the sessionStorage is keep without clear, which is user-friendly and is consistent between msedge and chrome,

0 Replies