Being stateless, WordPress doesn’t have an in-built way of handling session data. You can use cookies. You can implement PHP Sessions, but both have limitations and some hosts aren’t equipped to deal with them by default.

Early on we decided to adopt a solution based on whereby you have a cookie to identify each user, and have their session data stored in the WP options table. This worked well, and has served us nicely until now. There are however some drawbacks to this solution:

  • It’s hard to clear sessions since the options table contains other data
  • Scalability – Lots of sessions & transients mean slower queries on the options table
  • Performance – as above

The Github issue identifying these problems is here.

For the past few months some of the community, and Gerhard Potgieter who manages the store, have been experimenting with a custom session handler to work around these issues. At it’s core, it is pretty similar to our existing solution. However, it uses custom tables to store the data instead of the WP options table.

woocommerce-large-sessions has actually been running without issue on a few months now, so we’ve decided it is time to roll that into WooCommerce core.

A slightly modified version of the above has now been merged into 2.5 and is ready to test. If you would like to test the new session handler, just download master from Github.

Note: you may need to reactivate WooCommerce for the new table to be created.

We look forward to your feedback!