On this page
What this issue is
A session is the server's short-term memory of one visitor. The browser holds a small ID in a cookie, and the server uses that ID to look up the cart, login and other details. If the ID is not sent back, or the server cannot find or write the stored data, each page looks like a brand-new visit and the cart is empty.
Why it costs you leads or sales
Visitors who have chosen a product and lost it rarely start again. Ad clicks you paid for end at an empty cart. Because the site still loads and nothing shows an error, you may only notice when orders drop.
- Product pageVisitor clicks Add to cart
- Session savedCookie or session file fails
- Cart pageShows empty cart
- CheckoutNever reached
- PurchaseNo order, no purchase tag
The visitor adds a product, but the session is lost on the next page, so everything after it is lost.
Example: illustrative numbers only. A broken session can cut the share who keep their cart sharply.
How to check if your site has it
Use a clean browser window
Open a private window so no old cookies interfere. Add a product, then go to the cart.
Watch the cookies
Open DevTools, then Application (Chrome) or Storage (Firefox), then Cookies. Look for a session cookie such as PHPSESSID, woocommerce_cart_hash, wp_woocommerce_session_*, or cart (Shopify). Check it exists and stays the same between pages.
Check the response headers
In the Network tab, click the add-to-cart request and look for Set-Cookie. If it is missing, or the response is served from a cache, the session is not being created.
Compare browsers and domains
Try another browser, and try both www and non-www. If the cart works on one host name but not the other, the cookie domain is the cause.
Check server logs
Look in the PHP error log for 'session_start(): Failed to write session data' or 'open_basedir' or 'No space left on device'.
| Cause | Typical sign |
|---|---|
| Page cache serves cart pages | Cart empty for everyone; no Set-Cookie on cart or checkout |
| Session save path not writable or disk full | Errors in PHP log; cart empties at random |
| Cookie domain or path mismatch | Works on www only, or only after a redirect fix |
| SameSite or Secure flag wrong | Fails after redirect from a payment or another domain, or on http |
| Redirects between http/https or www/non-www | Cookie set on one host, cart read on another |
| Multiple servers with local sessions | Cart empties intermittently |
How to fix it
Fix the cause you found. Start with caching, because it is the most common one, then cookies, then server storage.
Exclude cart pages from caching
In your cache plugin or host cache, never cache the Cart, Checkout and My Account pages, or requests with the woocommerce_items_in_cart cookie. Most WooCommerce-aware cache plugins have this setting; check yours.
Match the site address
In Settings, General, make WordPress Address and Site Address use the same host (www or not) and https.
Clear caches and test
Purge page, object and CDN caches, then repeat the add-to-cart test in a private window.
Check the primary domain
In Settings, Domains, set one primary domain so visitors are not bounced between hosts that do not share the cart cookie.
Disable theme or app scripts
If the cart empties after an app change, switch to the default theme preview and disable recently added cart apps one by one to find the culprit.
Rule out a tag
Use Preview mode and pause custom HTML tags that touch cookies, redirects or cart links. A script that clears cookies or rewrites links can empty the cart.
Use one domain
In Project settings, Hosting, set a default domain so www and non-www redirect to one. Test Ecommerce cart on the published domain, not only the webflow.io one.
Keep the funnel on one domain
If the cart or order form is on a different domain from the previous step, the cookie is not shared. Put the steps on the same connected domain.
Check domain and custom code
Make sure the primary domain is set in your domain settings, and remove recent custom code in Settings, Custom code that sets cookies or redirects. Test again.
Set one primary domain
In Settings, Domains, set a primary domain so all other hosts redirect to it, then remove code injection that rewrites links or cookies.
Make the session path writable
Check session.save_path in php.ini points to a folder the web user can write to, and that the disk is not full.
Set cookie parameters correctly
Call session_set_cookie_params before session_start with the right domain, Secure and SameSite values (see the snippet below).
Share sessions across servers
If you run more than one server, store sessions in a shared place such as Redis or the database instead of local files.
<?php
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'domain' => '.example.com', // your domain, covers www and non-www
'secure' => true, // https only
'httponly' => true,
'samesite' => 'Lax',
]);
session_start();Broken
- Cart page is served from cache
- No session cookie is set or it changes each page
- Cart is empty after Add to cart
Fixed
- Cart and checkout bypass the cache
- One session cookie persists across pages
- Items stay in the cart through checkout
Session lost
Leads or data lost
The cart page loads empty. The visitor leaves and no purchase is recorded.
Toggle the cause to see the effect on the cart.
How to confirm it's fixed
- In a private window, add a product and open the cart: the item is still there
- The session cookie is present and unchanged across at least three page loads
- The cart survives moving between www and non-www, and http to https redirects
- Checkout shows the same items and totals as the cart
- Test in at least two browsers, including a mobile one
- PHP error log shows no session write errors
How to prevent it happening again
- Keep cart, checkout and account paths on the cache exclusion list after every cache, CDN or host change
- Watch disk space and the session folder size
- Test the add-to-cart journey after theme, plugin, PHP and hosting changes
- Keep one canonical domain with redirects
- Use shared session storage if you add servers
- Run an automated cart check on a schedule
How FunnelGuard handles this
FunnelGuard detects this today. Its cart assert check has a robot visitor add a product and then checks that the item is still in the cart on the next step. If the cart is empty, the check fails, FunnelGuard re-checks from a second region, and then sends one alert (email, Slack, Teams, WhatsApp, webhook or PagerDuty) with a screenshot and a likely cause.
Questions people ask
Why does my cart empty when I go to another page?
The server is not recognising you between pages. Usual causes are a cached cart page, a missing or blocked session cookie, a cookie set for a different domain, or session data that cannot be saved because of a full disk or unwritable folder.
Why is my WooCommerce cart empty after adding a product?
Most often the cart or checkout page is being cached by a plugin, host or CDN. Exclude the Cart, Checkout and My Account pages from caching, purge all caches and test again in a private window.
How do I check if the session cookie is being set?
Open DevTools, go to the Application or Storage tab and look at Cookies after clicking Add to cart. You should see a session cookie, and the add-to-cart response should include a Set-Cookie header. If neither appears, the session is not being created.
Can a www and non-www mismatch empty the cart?
Yes. A cookie set for one host name is not sent to the other, so the cart is lost when a redirect or link switches between them. Pick one canonical domain and redirect the others to it.
Can a full disk cause the cart to empty?
Yes. PHP file sessions are written to disk, and when there is no space the data fails to save. The PHP error log will usually show a session write failure or 'No space left on device'.
Why does the cart only empty for some visitors?
Browser cookie settings, SameSite rules after a redirect, several servers with separate session storage, or a cache that only serves some requests can all affect only part of your traffic. Test in several browsers and check whether you run more than one server.
How can I be alerted when the cart stops working?
Run an automated add-to-cart test on a schedule. FunnelGuard does this with a cart assert check, re-tests from a second region on failure and sends one alert with a screenshot and likely cause.
Related issues
- OPS-089Sticky sessions missing behind load balancerFix guide
- OPS-072Server out of disk space (uploads, sessions fail)Fix guide
- OPS-092Hosting migration left old server serving some trafficFix guide
- OPS-090One bad node behind load balancer (random failures)Fix guide
- OPS-073Memory / PHP memory_limit exhausted (white screen)Fix guide
- OPS-074CPU throttling / entry process limits on shared hostingFix guide