Cookies travel with matching requests
A server can ask the browser to store a cookie. On later matching requests, the browser can send it back. This makes cookies useful for server-recognized sessions, but it also means their scope and security settings matter.
Browser storage stays in the browser
Local and session storage hold strings for code running on the same site. They do not automatically travel with every request, so they are often used for local preferences rather than sensitive identity credentials.
A familiar example
Remembering a theme
- A visitor chooses Dark appearance.
- The site stores that preference for its own origin.
- On the next visit, the page reads the value early and applies the same appearance.
What to remember
- Storage should have a clear user-facing purpose.
- Cookies and local storage behave differently on requests.
- Do not place secrets in browser-readable storage.