I had a similar question to this one but the answers seem a bit cryptic and I'm still not quite "getting" localStorage
.
Local Storage is "local" in that exact browser and ONLY in that browser. To retrieve something stored in Local Storage, you must use the same browser, the same key and retrieve it from a page in the same origin (e.g. domain).
From the JavaScript code, HTML5 local storage may be accessed through a localStorage object on the global window object. The localStorage object stores the data without any expiration date. The data is not wiped, even after closing the browser, and may be accessed at any time.
Using HTML5 localStorage. Briefly speaking, localStorage works somewhat like a database; it stores some pieces of data – key and value – locally on the user's browser, which then can be retrieved using JavaScript API. Unlike Cookie, localStorage is persistent.
Local Storage Events You might have already used LocalStorage, which is accessible across Tabs within the same application origin. But do you know that it also supports events? You can use this feature to communicate across Browser Tabs, where other Tabs will receive the event once the storage is updated.
No, the data are persisted and aren't expired until you remove or clear them.
If you want the data removed when the users close the browser use sessionStorage instead.
No data persisted in private mode (incognito mode)
It shares data across the instances of a specific browser, for instance, Firefox tabs/instances share the same data but Chrome doesn't share the data with Firefox.
It also depends on the browser mechanism:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With