sessionStorage
A per tab store of up to about 5 MB that is cleared when the tab closes.
In one line
Can keep up to about 5 MB of notes for this tab until you close it
A per tab store of up to about 5 MB that is cleared when the tab closes.
Used for checkout steps and form state, and for trackers that carry a 'session ID' inside one tab. Different tabs of one site do not share it, so it cannot follow the person across tabs. Copied into a tab opened by window.open.
What it can and can't do
What the user does: Nothing. It happens as you move through steps or forms in the tab.
It can
- Remember form steps and choices while the tab is open
- Keep them when you reload the page
- Keep a separate set for each tab
It cannot
- Share them with your other tabs
- Keep them after you close the tab
- Let other sites see them
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 4 | 2010-01-25 | None |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 2 | 2006-10-24 | None |
| Safari | Supported | 4 | 2009-06-08 | None |
| Safari on iPhone | Supported | 3.2 | 2010-04-03 | None |
| Chrome on Android | Supported | 18 | 2012-06-27 | None |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | None |
How a site asks for it
| API | window.sessionStorage.setItem(k, v) |
| Browser compat keys | api.Window.sessionStorage |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| How long it lasts | Until the tab or window closes. Browsers may restore it after crash or tab restore |
| How to take it back | Clear site data, browser privacy settings |
| Inside an iframe | Not listed |
Data you get
What comes back: Key value strings
Shape: string
How often: any time
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
quota | integer | MiB | about 5 per origin | approximate |
Technical limits
- About 5 MiB per origin per tab
- Separate per tab even for the same origin
- Cleared on tab close
- Cloned (not shared) when a tab is duplicated
The story
What it is
A store of up to about 5 MB for one tab that is cleared when you close the tab.
For you
You never see it. It is why a form can hold what you typed while you click through the steps, and why a new tab starts fresh.
For makers
Makers use it for short lived state like multi step forms and temporary tokens. It is safer than long term storage, because it disappears with the tab. It is also used for session IDs in analytics.
Where you see it
| Type | Example | Apps |
|---|---|---|
| shopping | A checkout keeps your shipping choices while you move through the steps. | None named |
| banking | A bank keeps a short lived token in the tab and loses it when you close it. | None named |
| games | A browser game keeps the current level in a tab but does not save it forever. | None named |
| travel | A booking site keeps your search and seat choices while you compare flights. | None named |
| analytics | A site analytics script uses it to mark one visit as one session. | Google Analytics |
| education | An online test keeps your answers in the tab until you submit. | None named |
Risks
- Lost on tab close
- Readable by page scripts
What the platform says
- MDN: Window.sessionStorage. Documents how a page can keep data for the life of one tab.
Good uses and abuse
Legitimate uses
- Multi step flows, scroll position
Known abuse
- Per tab session IDs for analytics
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 2 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 0 | Rough identifying entropy, when known |
History
- 2023-07, Chrome 115: Third party sessionStorage partitioned by top level site
Related capabilities
Related
- localStorage. Can keep up to about 5 MB of text notes per site, until cleared
Sources
How well checked: Based on official documentation.