Guides / Web

Cookie vs LocalStorage vs SessionStorage: what websites keep in your browser

Three browser storage mechanisms can all remember state, but their lifetime, request behaviour and security properties differ.

PUBLISHED · UPDATED · 8 MIN

Cookies, LocalStorage and SessionStorage can all remember state, but they behave differently.

Security differences matter

JavaScript can read LocalStorage, so storing passwords or long-lived high-value secrets there is a poor design. Session cookies can instead use controls such as HttpOnly, Secure and SameSite to reduce specific risks.

Why clearing site data logs you out

A browser cleanup may remove session cookies, local storage, IndexedDB and service-worker state, not just cached images. The site then loses the information that linked your browser to an authenticated session.

The mobile debugging guide shows where to inspect these stores before wiping them.