Estimated reading time : 5 min · Published
Explain where data stays
localStorage retains data for an origin across sessions; sessionStorage belongs to a page session in a tab. An origin distinguishes protocol, host and port. Data stored on an HTTP version does not automatically appear on its HTTPS version.
The word ‘local’ does not guarantee encryption or isolation from scripts on the same origin. Describe the exact data retained and avoid storing secrets. On shared devices, provide a clearing action and explain its scope.
The storage event is not sent to the window making the change. With localStorage, it can notify other same-origin tabs sharing that storage area. With sessionStorage, it concerns other same-origin documents within the same tab, such as an iframe, rather than an independent tab. If a new window has an opener, its sessionStorage may start as a copy; the two areas then remain separate.
Fictitious test: two tabs open revision r7 of a draft and each edits it. Rereading the revision before replacing a value may reveal a conflict, but does not make the read-and-write sequence atomic. The storage event is neither a lock nor server synchronization. Decide how to retain both changes or request a choice instead of claiming an automatic merge that has not happened.
Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.
| Situation to test | Documented behavior | Interface consequence |
|---|---|---|
| A window writes to localStorage | Other same-origin contexts sharing the area can receive storage. | Update the writing window too, without waiting for its own event. |
| The window initiating the write | It does not receive its own storage event. | Confirm the actual success of the write locally. |
| Two independent tabs and sessionStorage | Their areas are not synchronized by this event. | Do not promise automatic recovery of input in the other tab. |
| New window with an opener | An initial sessionStorage copy may be created, then evolve independently. | Test subsequent edits; an initial copy is not continuous sharing. |
- MDN : storage event
Consulted on 22 October 2026; event recipients and local versus session storage.
- MDN : sessionStorage
Consulted on 22 October 2026; separation by tab and possible initial copy from the opening window.
Plan for unavailable or lost storage
Browser settings, quotas, deliberate clearing and some private contexts can prevent retention or remove a copy. Rules vary by browser and API. A theoretical quota does not guarantee storage on a visitor’s device.
Handle read and write failures. If persistence fails, preserve active input where possible and clearly report that work remains usable in this page but persistent retention is unconfirmed. Do not announce ‘saved’ before an actual successful write.
Provide a documented export
For an important log or configuration, offer an export containing format, version, date and stable item identifiers. Recovery should not depend on the current visual order of rows. Avoid automatically collecting device details or unrelated information.
Requesting a download does not prove that the visitor kept the file. Phrase feedback accordingly and explain how to retain it. An export is not a secure sharing space: the person distributing it remains responsible for its contents.
Validate the whole import before applying it
Check size, format, version, types, expected fields, lengths, known identifiers and duplicates. Prepare the result in memory, then replace visible data after every check succeeds. A rejection must not leave half an imported log.
Display notes as text without interpreting HTML. Try an empty file, truncated JSON, an older format and strings containing special characters. When site changes alter an observation’s meaning, request a fresh review rather than automatically trusting a previous ‘passed’ result.
Test clearing and recovery
Check what each action clears: active input, one tool’s stored key or an entire account. Clearing one tool should not unnecessarily remove all site preferences. Previously downloaded exports remain independent copies.
This site’s budget and acceptance tools can be used without an account. The acceptance log exports to resume a review; directory selections retain browsing preferences when storage is available. Check each tool’s behaviour instead of assuming they all retain the same data.
Recovery case: the file imports but records are missing
Synthetic example: an exported acceptance log contains twelve checks, but restoration displays only nine. Compare identifiers and required fields before concluding that the download is usable. An import confirmation without reconciliation does not establish recovery. Rejected records need a clear reason without erasing the currently open log.
Keep an export of the initial state, work on a copy and compare the number, text, status and notes of each check. Also import the same file twice: the stated behaviour must distinguish replacement and merge without silent duplicates. Recovery should remain usable when the browser refuses local writes, rather than relying only on a saved indicator.
Assess a targeted reset without silently deleting useful drafts.
Synthetic case: old local data breaks a journey after an incompatible change. In a disposable profile, inventory what will be removed and test chosen directives. Warn people if drafts are affected. Clearing the browser does not by itself revoke sessions or data retained on the server.
- Removal matches the announced scope, useful data can be exported and server sessions are addressed separately.
- MDN Clear-Site-Data
HTTPS header signalling removal of selected site-related browser data categories, depending on browser support.
Reference documents
- MDN : Web Storage · Source consulted
- MDN : quotas and eviction · Source consulted
- MDN Clear-Site-Data · Source consulted
Content updated on
