Glossary
Glossary Local Storage

Local Storage

Also known as: localstorage, web storage, sessionstorage, session storage
TechWeb Standards

Definition

A browser key-value store scoped to an origin, holding strings, surviving reloads and restarts, readable and writable only by JavaScript and never sent to the server — with sessionStorage as the same API scoped to one tab

The distinction from a cookie is what it is for. A cookie is sent on every request, so it is how a server learns who you are; local storage is never sent, so it is how the browser remembers what only the browser cares about. This site’s theme and appearance settings live here — uxlab-theme is read before the first paint and written to documentElement.dataset — because a server that knew the reader’s theme would gain nothing and a cookie would put it on every request for no reason.

Tech

The browser's own notebook: per origin, strings only, never leaves the machine on its own.

Avoid: keeping a token in it. It is readable by any script on the origin, which makes a single cross-site scripting bug a credential theft; that is the argument for an HttpOnly cookie. Also avoid reaching for it during server rendering — it does not exist there, and the mismatch shows up as a hydration error rather than as a missing value.

Related Terms

  • a: Appearance
  • ?: Keyboard shortcuts