Cookies and browser storage · EP08

How Do Websites Remember Your Cart?

Yesterday’s jacket. Today’s cart. What did the browser actually save?

Quick Answer

A shop can save a cart ID in your browser and use it to retrieve a cart stored on its servers. In this example, the browser keeps C42; the shop keeps the jacket list.

One cart. Three different places.

Fictional shop. Controls change only this example.

Pip at his laptop, with Nagi beside him
On the page
Yellow jacket1 item · J4

In the browser

Cart cookie
Cart ID: C42

At the shop

Cart C42
Yellow jacket · J4
Nagi

C42 lets this page find the shop’s jacket list.

About this example

One ordinary browser, a persistent cart cookie with the fixed ID C42, and one shop record. The cookie remains valid until removed; the shop record remains until deleted here. Returning does not create a new ID. No account sync, alternative identifier or Web Storage fallback is included. Other sites may store carts differently. These controls do not close a real tab or delete real service data.

Closing a page, removing a browser clue and deleting a service record are different actions. Recognizing the difference helps explain why a remembered cart can survive without an account.

More on this page

Illustrated Explanation

Pip leaves a yellow rain jacket in his cart. He closes the page, then returns in the same browser. The jacket is still there. The model above lets you inspect what the page, the browser and the shop each keep.

How It Works

The shop’s record for Cart ID C42 contains jacket J4. The browser keeps C42 in a cookie. Returning with that still-valid clue lets this shop look up the corresponding list. The label is not the jacket, and it need not contain every item in the cart.

The page is what Pip sees. The cookie is a saved clue. The jacket list is a shop record. Changing one does not necessarily change the others. An account can offer another way to associate a saved cart, but this example does not need one.

A preference can also be stored in the browser. In the episode, a saved language choice illustrates a different kind of data from a server-side product list. The exact storage design belongs to this example; it is not a claim that every cart or preference works this way.

What Changes in This Example?

Remove C42 from the browser and this page can no longer find its matching cart. The jacket list remains at the shop until it is deleted separately.

Switch browsers: the cart ID may not come with you.

A different browser does not automatically have C42. Some services also save carts through an account; that is a different arrangement from this example.

Close the tab: that is not the same as logging out.

Closing a page removes it from view. Logging out is a separate action that should end an authenticated session. Follow the actual service’s controls when using a real account.

Key takeaways

  • Distinguish what is displayed, what the browser saves and what the service keeps.
  • An identifier can point to a separate cart without containing its items.
  • Removing a browser clue is not the same as deleting the service’s record.
  • The fictional design explains a mechanism, not every website’s implementation.

Evidence & Limitations

Read the technical sources and their limits

Cookies and a saved identifier

MDN describes cookies as small data associated with requests under defined conditions. Its guidance covers session management, expiration and the possibility of browser session restoration. It supports the general mechanism, not a guarantee that closing any browser deletes every cookie. Cookie guidance

Browser storage has different roles and limits

The Web Storage API distinguishes local and page-session storage. These mechanisms should not be conflated with a service’s server-side login session. Web Storage

Storage has limits, browser policies and deletion conditions. A persistent storage mechanism is not a promise of permanent retention. Storage limits

A session needs a defined lifecycle

OWASP’s developer guidance discusses session invalidation and the limits of relying on browser-close events. This is guidance for implementing services, not a survey establishing that all sites behave correctly. Session guidance

The episode uses a deliberately specified shop to separate a saved browser clue, a server record and the page on screen. It is not a live account experiment, and it does not establish the implementation of a named retailer.

Follow the related question: why an ad can seem to follow you. Remembering a useful cart and the rules of advertising are related questions, not identical processes.

Common Misconceptions

Closing the page empties every storage location.

A closed tab is not proof that browser data or server records were deleted.

The cookie must contain the whole shopping cart.

In this shop it contains an identifier. The item list is kept separately.

Watch the corresponding episode

How Do Websites Remember Your Cart?

The player connects to YouTube only when you choose to load it. YouTube then receives technical request data and this site's origin, and its data processing applies. Privacy information.

Watch directly on YouTube →
Editorial notes

Source review date: . Retained evidence and access limitations are identified in the source notes.

About this explanation

Adapted from TDQ production scripts and research with AI-assisted drafting. Pip and Nagi's examples are fictional. Website approval: human-approved revision. Prepared . Editorial approach.

Sources & further reading

  1. MDN — Using HTTP cookies

    Cookies and eligible requests; persistence and session-restoration qualifications. The shop is an explicitly defined fictional model.

  2. MDN — Web Storage API

    Browser storage types and scope; not evidence of a named shop’s implementation.

  3. MDN — Storage quotas and eviction criteria

    Storage limits and possible deletion; no guarantee that local data lasts forever.

  4. OWASP — Session Management Cheat Sheet

    Session lifecycle and explicit server-side invalidation. Recommendations do not establish that every service follows them.