
In a recent Business Bloomer Club Slack thread, a discussion unfolded around WooCommerce cart session management—specifically how long guest carts are stored before expiration.
A core WooCommerce function confirmed the default behavior: sessions expire after 48 hours, with a soft expiration at 47 hours.
This raised further questions about whether the session expiry is extended after a cart update, and how this differs between guest and logged-in users.
Digging deeper, the conversation touched on the role of the _woocommerce_persistent_cart_
option for logged-in customers, and whether it’s still necessary given longer session durations.
Interestingly, this debate coincided with a new WooCommerce pull request suggesting the removal of persistent carts entirely in favor of simpler session management.
If you’ve ever wondered how WooCommerce stores cart data or how it behaves across different users, this post summarizes key findings and links directly to WooCommerce core code and discussions that could impact future releases.
WooCommerce Session Expiration: The Basics
WooCommerce uses its own session management system to store cart data for both guest and logged-in users. The default expiration for these sessions is 48 hours.
Here’s the relevant bit of code:
public function set_session_expiration() {
$this->_session_expiring = time() + intval( apply_filters( 'wc_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
$this->_session_expiration = time() + intval( apply_filters( 'wc_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
}
This means the session is marked as “expiring” at 47 hours, and actually expires at 48. These durations can be filtered using the wc_session_expiring
and wc_session_expiration
filters, giving developers full control over the lifetime of cart sessions.
Session Extension and Cart Updates
One might assume that sessions expire precisely 48 hours after they’re created, but that’s not entirely accurate. As confirmed in the Slack thread, sessions get extended if cart activity occurs close to expiration time.
In other words, if a user returns to their cart and interacts with it before it expires—especially near the end of the session window—WooCommerce can renew that session automatically. This behavior is intended to improve the shopping experience and reduce cart abandonment caused by expired sessions.
Are These Sessions Only for Guest Users?
Initially, you might think WooCommerce sessions are only relevant to guest (logged-out) users, but that’s not the case. WooCommerce uses the same session mechanism for both guest and logged-in users.
However, there is an additional mechanism that comes into play for logged-in users: the persistent cart.
What Is a Persistent Cart?
A persistent cart stores a user’s cart in the WordPress usermeta
table. This means that if a logged-in user adds items to their cart, logs out, and returns a week later, their cart will still be there—regardless of session expiration.
This is managed by the _woocommerce_persistent_cart_{blog_id}
meta key.
By default, this persistent cart functionality is enabled. Developers can disable it using the following filter:
add_filter( 'woocommerce_persistent_cart_enabled', '__return_false' );
This approach has been in WooCommerce for years (seven, to be precise), and complements the session system rather than replacing it—until now.
Is Persistent Cart Going Away?
In what could only be described as a jinx, a Slack member jokingly asked if one of the two systems—sessions or persistent cart—was going to be deprecated.
And wouldn’t you know it, Pull Request (#57961) was just opened on GitHub to remove the persistent cart in favor of longer-duration sessions.
The proposal outlines a few motivations:
- Reduce complexity by relying solely on one system.
- Simplify debugging and session handling.
- Make the cart experience more consistent across users.
This shift implies that session storage will be relied upon for both guest and logged-in users, potentially with longer default durations or enhanced session management tools.
Implications for Store Owners and Developers
If the persistent cart feature is indeed removed, developers maintaining custom cart-handling code may need to revisit how they preserve cart data for logged-in users.
For store owners, the change should be mostly transparent—unless they rely on the persistent cart behavior for specific use cases, like remembering carts across devices or syncing them across sessions.
Still, this highlights the importance of keeping WooCommerce installations updated and testing customizations that may be affected by core changes.
Monitoring Sessions: A Developer’s Tip
If you’re curious about session data in WooCommerce, here are a few tools and techniques:
- WC()->session: You can interact with session variables via
WC()->session->get()
andWC()->session->set()
. - wp_wc_session_ tables*: WooCommerce stores sessions in custom database tables you can query directly.
- Cookies: WooCommerce uses cookies (like
wp_woocommerce_session_
) to track session IDs.
Understanding these layers helps developers and advanced store owners better troubleshoot and build enhancements around the cart and checkout experience.
Conclusion
This thread highlights just how layered WooCommerce’s session and cart storage system is—and how even long-standing features like persistent cart may be phased out in favor of simplification.
While sessions expire by default after 48 hours, their behavior is influenced by user interaction, filters, and the type of user (guest vs logged-in). If persistent carts are eventually deprecated, developers and merchants will need to rely even more on the flexibility of the session system.
Staying informed of these changes—and testing their impact—is key to ensuring a reliable and conversion-friendly shopping experience on your WooCommerce store.