AI Workshop: learn to build apps with AI →
Storage: Session vs local storage

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


Both Session Storage and Local Storage provide a private area for your data. Any data you store cannot be accessed by other websites.

Session Storage keeps the data stored in it for the duration of the page session. If multiple windows or tabs open the same site, each has its own Session Storage instance.

When a tab/window is closed, the Session Storage for that particular tab/window is cleared.

Session Storage allows different tabs or windows to use the same site independently, which is not possible with cookies because they are shared across all sessions.

Local Storage persists the data until it is explicitly removed, by code or by the user. It is never cleared automatically and is shared across all sessions that access the site.

Both Local Storage and Session Storage are protocol-specific: data stored when the page is loaded over http is not available when the page is loaded over https, and vice versa.

Web Storage is only accessible in the browser. Unlike cookies, it is not sent to the server.

Both Local and Session Storage are available on the window object, so you can access them using sessionStorage and localStorage.

Both expose the same set of properties and methods through the Storage interface.

The Storage object has one property, length, which is the number of data items stored in it.

Lessons in this unit:

0: Introduction
1: ▶︎ Session vs local storage
2: Setting an item
3: Getting an item value
4: Removing an item
5: Clearing storage
6: Storage size limits