A customer logs out of your store on the family computer. An hour later, someone else logs in and finds a cart full of products they never picked. On a B2B store it can be worse: the next person sees another account's order, quantities and trade prices.
This isn't a bug in your theme. It's how Shopify carts work, and it happens on every store.
Shopify keeps the cart in a cookie called cart, stored in the browser. That cookie holds a cart token, not a customer ID. The cart belongs to the browser, not to the customer account.
Logging out ends the customer's session. It doesn't touch the cart cookie. So the cart stays where it was, ready for whoever uses that browser next.
It's also why carts disappear across devices: the cart never travels with the account.
Most shoppers use their own phone, so they never notice. It matters when several people share one browser:
In each case, the next customer sees products that aren't theirs. On a wholesale store that hides prices from the public, that's a privacy issue, not just a confusing cart.
The common answer on the Shopify forums is a few lines of JavaScript that call /cart/clear.js when the customer logs out. Shopify's Ajax Cart API documents this endpoint: it sets the quantity of every line item to zero.
It solves the privacy problem, but it creates another one: the cart is gone for good. When the customer logs back in, on this computer or another one, the cart is empty. A buyer who spent an hour building a 40-line order has to start over.
Two more things to know:
If what you need is a button that lets customers empty their own cart, see our guide to adding a clear cart button.
What you want is two things at once: an empty cart on the shared computer, and the customer's cart waiting for them when they come back.

That's what Ecto does with its Auto-clear carts on logout option:
If your customers share devices, turn the option on. Without it, the cart left in the browser becomes the cart of the next customer who logs in. Ecto then saves it to their account, because the most recent cart always wins.
We saw this with one of our B2B merchants. Their sales reps log into several client accounts on the same laptop, and the first client's cart kept following them into the next account. Turning on auto-clear on logout fixed it.
Ecto works with any Online Store theme and with the new customer accounts (login with an email code). 3‑click setup, no code, no theme edits. Carts are saved for logged-in customers only, and kept for 90 days after their last change.
Log in on the Ecto demo store, add a product, log out, then log back in on your phone. Your cart is there. When you're ready, start a free trial from the Shopify App Store.
Out of the box, logging out doesn't clear the cart. You can call /cart/clear.js when the customer logs out, but then the cart is lost for good. With Ecto's Auto-clear carts on logout option, the cart is emptied in that browser and restored when the customer logs back in.
Shopify stores the cart in a browser cookie, not in the customer account. Logging out ends the session but leaves the cart cookie in place.
Yes, if one logs out and the next one uses the same browser. Clearing the cart on logout prevents it.
Not for every customer. Shopify syncs carts through Shop for customers who have a Shop account. For everyone else, the cart stays in the browser.
No. It only sets quantities to zero. The cart note and cart attributes stay.