Privacy & Tech

Knowledge Base | Privacy & Tech | What is local storage, and how is it different from cookies?

What is local storage, and how is it different from cookies?

Local storage is a browser feature that saves key-value data through the localStorage API. It can retain information between visits, including after the browser is closed, unless the data is cleared or removed.

Aspect

Local storage

Cookies

Sending data to a server

Not sent automatically; scripts can read and transmit it.

Eligible cookies accompany matching HTTP requests automatically.

Expiration

No built-in expiry for individual items.

Can have an expiry or last for a browser session.

Storage scope

Separated by origin: protocol, hostname and port.

Governed by domain, path and other cookie attributes.

Typical role

Keeping browser-side application data or preferences.

Maintaining sessions, preferences or identifiers.

MDN’s localStorage documentation explains its behaviour. A website that needs local storage data to expire must implement its own expiry logic.

Local storage can also hold tracking identifiers. Replacing a cookie with local storage does not avoid device-storage requirements; the purpose must still be assessed to determine whether user consent is needed.