I recently started experiencing a strange issue on my Shopify store after making several theme customizations and performance optimizations. Customers can browse products normally at first, but after spending a few minutes on the website they suddenly get logged out or their cart becomes empty without warning. In some cases, users add products successfully and continue shopping, but the cart resets completely when they move to another page or refresh the browser. The issue happens inconsistently and affects both desktop and mobile visitors. Because of this, some customers believe the store itself is malfunctioning and leave before completing checkout.
What makes the situation more confusing is that the problem does not affect every visitor in the same way. Some customers report that their accounts remain active for hours without issues, while others lose session data within just a few minutes of browsing. I checked browser console logs and occasionally noticed cookie-related warnings and delayed session storage updates, but there are no obvious fatal errors. The strange part is that Shopify admin itself shows normal activity and no failed checkout alerts during these incidents. This makes it difficult to determine whether the issue is caused by frontend code, caching behavior, or some hidden theme conflict.
The problem started shortly after I customized the store theme to improve loading speed and reduce unnecessary scripts. I removed several third-party apps, optimized JavaScript files, and adjusted lazy loading settings for product pages and collection images. Although the website performance improved visually, customer session stability became noticeably worse afterward. I also tested the store with a clean duplicate theme and the issue appeared less frequently there, which makes me suspect something inside the customized production theme is interfering with Shopify’s session handling. However, I still cannot identify the exact technical cause behind it.
Another detail I noticed is that the issue becomes much more common during periods of higher traffic or when multiple tabs are opened simultaneously. Some users report that opening product pages in separate tabs immediately causes the cart count to desynchronize or disappear entirely. Others mention that checkout redirects occasionally send them back to the homepage while clearing all previously selected products. I tested this behavior across Chrome, Firefox, Safari, and Edge, and while the symptoms vary slightly between browsers, the underlying session instability remains consistent. Mobile browsers appear to be affected more often than desktop environments.
I also attempted several troubleshooting methods including clearing Shopify cache, disabling browser optimization apps, removing custom AJAX cart functions, and reverting parts of the theme code to older backups. Unfortunately, none of these steps permanently solved the issue. I even checked whether external security or CDN settings might be interfering with cookies or session persistence, but server logs do not show any obvious request blocking or abnormal traffic behavior. The most frustrating part is that the problem appears randomly, making it difficult to reliably reproduce for testing and debugging purposes.
At this stage, I would really appreciate guidance from anyone who has experienced similar Shopify session or cart persistence problems after modifying a theme. I am trying to understand whether this behavior is typically caused by JavaScript conflicts, cookie handling issues, AJAX cart implementations, or Shopify caching behavior under load. My goal is simply to maintain a stable shopping experience without forcing customers to repeatedly log in or rebuild their carts. If anyone has dealt with random cart resets, customer logout loops, or inconsistent session behavior after theme optimization, I would genuinely appreciate advice on the best direction for further debugging.