The cart is found through one cookie, cart. A cart that "empties" is nearly always a browser that stopped sending it, so compare the cookie in the browser's developer tools before and after it happens. In order:

  1. A different hostname. The cookie is set for the exact hostname, so example.com and www.example.com have separate carts. Redirect every hostname to one.
  2. The shopper signed out. Sign-out clears the cookie. A member's cart stays on their account and comes back when they sign in.
  3. The order was placed. Purchased items leave the cart, and a cart left empty is deleted.
  4. The page was served over plain http. The cookie is always Secure, so a browser does not keep it from an http page, and every page starts a new cart. Look for this behind a local proxy or on a preview hostname without a certificate.
  5. Another browser, a private window, or cleared cookies. A guest cart then comes back only through its restore link.
  6. A guest cart expired. It is deleted 180 days after its last change (the Carts Lifetime setting). A member's cart is kept.

Three things look like an empty cart and are not. A count rendered on a cached page shows another visitor's cart (next question). GET /cdna-api/cart answers 404 for a visitor with no saved cart, which is an empty cart, not an error. And items that can no longer be bought stay in the cart marked unavailable, left out of the total, and are not carried into the checkout, which can read as "my items vanished". Show unavailable lines with a remove button (the cart cookie).