JavaScript Window sessionStorage Property

Beginner
5 min read
Updated: Nov 2026
3 examples
Property

Definition

window.sessionStorage is a Storage object for this origin that lasts until the tab closes.

Syntax

Read window.sessionStorage with no parentheses.

JavaScript
window.sessionStorage;
CallWhat it does
window.sessionStorageOrigin storage that lasts for the tab session.

Window property in browsers. No import required.

Parameters

ParameterDescription
window.sessionStorageRead-only or assignable depending on the property. No function arguments.

Return Value

Return ValueDescription
*Origin storage that lasts for the tab session.

JavaScript Examples

Example 1 — Basic Read

Beginner example for window.sessionStorage.

JavaScript
sessionStorage.setItem("step", "2");
console.log(sessionStorage.getItem("step"));
sessionStorage.removeItem("step");
Try It Yourself

How It Works

  1. Step. Same API as localStorage.
  2. Step. Data is tab-scoped.

Example 2 — Practical Use

Beginner example for window.sessionStorage.

JavaScript
console.log(window.sessionStorage === sessionStorage);
console.log(typeof sessionStorage.setItem);
Try It Yourself

How It Works

  1. Step. Global alias matches.
  2. Step. Methods: setItem, getItem, removeItem, clear, key.

Example 3 — Check / Compare

Beginner example for window.sessionStorage.

JavaScript
sessionStorage.setItem("tmp", "yes");
console.log(sessionStorage.getItem("tmp"));
sessionStorage.clear();
console.log(sessionStorage.getItem("tmp"));
Try It Yourself

How It Works

  1. Step. clear empties this tab’s session storage.

Browser & Runtime Support

window.sessionStorage is a standard Window property in browsers.

✓ Browser Window API

window.sessionStorage

Available in all modern browsers. Not used in plain Node.js without a DOM.

Browsers Environment
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
window.sessionStorage Excellent

Bottom line: Safe in browsers. Skip in server-only Node scripts.

Frequently Asked Questions

Key/value storage for the current tab session.
When the tab/window is closed (session ends).
Yes β€” setItem, getItem, removeItem, clear, key, length.
Open the Window Properties index for every property in this series.

Browse more properties

Continue through the Window properties list.

Next →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P πŸ”—

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful