Categories
Core

New session handler in 2.5

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 https://github.com/ericmann/wp-session-manager 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 woothemes.com 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 WooThemes.com 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!

By Mike Jolley

I help build things at Automattic.

9 replies on “New session handler in 2.5”

I have been using this settings in my nginx sites-enabled cnfiguration file :-

location ~ \.php$ {

set $rt_session “”;
if ($http_cookie ~* “wp_woocommerce_session_[^=]*=([^%]+)%7C”) {
set $rt_session wp_woocommerce_session_$1;
}
if ($skip_cache = 0 ) {
more_clear_headers “Set-Cookie*”;
set $rt_session “”;
}
fastcgi_cache_key “$scheme$request_method$host$request_uri$rt_session”;

try_files $uri =404;


}

Do I need to make any modifications, given that the WooCommerce v2.5 (Major) has moved to using Session handler, Or the wp_woocommerce_session is still in use ?
I will be waiting for some time to be clear on this topic before upgrading Woocommerce in production site.

Like

Hi… not sure if this is a bug or a configuration error on my end, but with at least one site I manage, the 2.5.0 update failed to create the woocommerce_sessions data table, resulting in several days of zero orders for the client until I was able to identify the issue and manually create the table.

Like

Comments are closed.