Skip to main content
All Terms Glossary

Session Storage

Definition

Session Storage is a web storage API that maintains a separate storage area for each origin that's available for the duration of the page session. Unlike Local Storage, data persists only as long as the browser window remains open. While more temporary than Local Storage, it still requires security considerations for stored sensitive data.

What Session Storage is

Session Storage is a Web Storage API almost identical to Local Storage in shape: synchronous string key-value pairs scoped to an origin, read through window.sessionStorage. The difference is lifetime and scope. Data lives only for the duration of the page session, which in practice means a single tab or window. Closing that tab clears the store, and a second tab opened to the same site gets its own empty, independent Session Storage rather than sharing the first tab's data. Reloading or navigating within the same tab preserves it. This makes Session Storage a natural fit for short-lived, per-tab state such as a multi-step form's progress or a one-time UI flag that should not leak between tabs.

Why it matters for security

The per-tab, auto-clearing lifetime slightly narrows the exposure window compared with Local Storage, but the core risk is unchanged: any JavaScript running on the origin can read the entire Session Storage area, and it cannot be marked HttpOnly. A cross-site scripting payload or a malicious third-party script executing in the same tab can dump every key while the tab is open. Values are stored unencrypted and in plaintext. So while a session token in Session Storage vanishes when the tab closes, it remains fully readable to hostile script for as long as the user keeps that tab active, which is often the entire working session.

How to use it safely

Prefer Session Storage over Local Storage when data genuinely only needs to survive within one tab, since the shorter lifetime reduces the blast radius of a stolen value. Even so, do not treat it as a secure vault: keep real authentication credentials in HttpOnly, Secure cookies, and store only non-sensitive working state here. Validate and encode any value read back before it touches the DOM to avoid DOM-based XSS. A strict Content Security Policy reduces the chance that untrusted script runs at all. cside's payload-level analysis of third-party scripts helps here by flagging a vendor script that begins reading browser storage it has no reason to touch.

Definition

What is the difference between Session Storage and Local Storage?

Both store string key-value pairs per origin and are readable by any script on that origin. Local Storage persists until explicitly cleared and is shared across all tabs of the origin. Session Storage is isolated to a single tab and is wiped when that tab closes, giving it a shorter, narrower lifetime.

Definition

Does Session Storage persist across a page refresh?

Yes. Reloading the page or navigating within the same tab keeps Session Storage intact, because the page session continues. It is only cleared when the tab or window itself is closed, or when the storage is cleared programmatically or by the user.

Got more questions

Talk to a security expert

We answer client-side security questions every day. Bring yours.

Book a demo

Want to walk through this with an engineer?

Thirty minutes, on your own site. Not a slide deck.

We'll show you:

Which third-party scripts are running on your site right now
Where you stand on PCI DSS 6.4.3 and 11.6.1
How much of your traffic is bots and AI agents

Rather just send a question?

Finding open slots…

Real humans only. We'd know.

Having trouble booking? Open scheduler in a new tab

What are you trying to solve?

Tell us in a line and we'll come back with something useful, not a generic pitch.

We usually help with:

Seeing which third-party scripts run on your site
PCI DSS 6.4.3 and 11.6.1 evidence
Bots, AI agents and account takeover

Prefer to just book a time? Pick a slot instead