Kubernetes and WooCommerce cart issues

3/2/2018

When I run multiple instances of WordPress on Google Kubernetes Engine and drop session affinity I get weird behavior in the cart, items disappear and come back. And people get logged out. (When I use session affinity, 100% of my traffic gets sent to one pod).

It seemed to be an issue of session persistence, but from what I can tell, WordPress relies on cookies to store login and cart info rather than sessions so this shouldn't be an issue. Locally when I use docker, destroy the container, and restart my cart remains so this seems to confirm that.

What is going on? And more importantly, what can I do to fix it?

-- Steve
google-compute-engine
kubernetes
wordpress

1 Answer

3/2/2018

It looks like woocommerce uses PHP sessions for Cart info:

https://docs.woocommerce.com/wc-apidocs/source-class-WC_Cart.html#108 https://docs.woocommerce.com/wc-apidocs/class-WC_Cart_Session.html

By default, that data would be stored on the specific pod file system. There are ways of telling PHP in multihost environments to use a common session store.

-- Jonah Benton
Source: StackOverflow