Currently, I am storing a few things in local storage like the last visited page. I need them even when the user logs off and logs in again. I was planning to move them into Session storage and thus I wanted to know the validity of items in Session Storage of browser.
Asked
Active
Viewed 422 times
-1
-
Read this [link](https://www.w3schools.com/jsref/prop_win_sessionstorage.asp). If you want to keep the data even after the browser windows is closed, try using cookies – Chin. Udara Dec 10 '19 at 06:35
-
`sessionStorage` doesn't really expire (for a particular window/tab), but data is persisted until the user explicitly clears it. [here's](https://stackoverflow.com/a/8537188/9172668) a good answer that quickly highlights it. You can set up a [timeout](https://www.w3schools.com/jsref/met_win_settimeout.asp) then clear the storage with `sessionStorage.clear()` – sassy_rog Dec 10 '19 at 06:43
1 Answers
1
The items in session storage are only available in a page's session.
A page session lasts as long as the browser is open, and survives over page reloads and restores.
Opening a page in a new tab or window creates a new session with the value of the top-level browsing context, which differs from how session cookies work.
Opening multiple tabs/windows with the same URL creates sessionStorage for each tab/window.
- Closing a tab/window ends the session and clears objects in sessionStorage.

Kaiido
- 123,334
- 13
- 219
- 285

Ajay Ullal
- 378
- 2
- 10