Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could someone explain the life of a sessionStorage object?

I've looked at a few websites and each of them are slightly different. I understand the basic functionality, but its life time is not so obvious. On Google (Developers) it said it only exists for a specific tab in that instance, but others said you could access it from the same tab or other tabs as long as its the same domain name. Could someone please clear that up for me. Thanks.

like image 261
Andy Avatar asked Jan 20 '12 17:01

Andy


People also ask

What is the lifetime of session storage?

Session Storage is a global object that maintains a storage area that's available for the duration of the page session. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated.

Is it safe to store data in sessionStorage?

Vulnerability to Cross-Site Scripting (XSS) Attacks XSS attacks inject malicious scripts into web applications, and unfortunately, both LocalStorage and SessionStorage are vulnerable to XSS attacks. XSS attacks can be used to get data from storage objects and add malicious scripts to the data stored.

Does sessionStorage persist after refresh?

The sessionStorage object stores data only for a session. It means that the data stored in the sessionStorage will be deleted when the browser is closed. A page session lasts as long as the web browser is open and survives over the page refresh.


1 Answers

Session Storage is a global object that maintains a storage area that's available for the duration of the page session. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated.

source: https://developer.mozilla.org/en-US/docs/DOM/Storage

like image 188
SKen Avatar answered Sep 29 '22 22:09

SKen