Solice UI
Back to the curriculum

Chapter 1 · How the Web Works

Cookies and browser storage

HTTP messages do not automatically remember earlier visits. Sites use cookies and browser storage when a later page needs a small piece of earlier context, such as a session or appearance choice.

Beginner · Lesson 6 of 6 in this chapter

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.

Remembering a theme

  1. A visitor chooses Dark appearance.
  2. The site stores that preference for its own origin.
  3. On the next visit, the page reads the value early and applies the same appearance.
  • Storage should have a clear user-facing purpose.
  • Cookies and local storage behave differently on requests.
  • Do not place secrets in browser-readable storage.