Support » Plugin: WooCommerce Rejoiner » Remove session_start() Dependency

  • Recently I noticed hundreds of thousands of empty sessions on our server. I finally traced the culprit to line 15 of class-wc-rejoiner.php:

    class WC_Rejoiner extends WC_Integration {
        public function __construct() {
            session_start(); // <-- line 15
            $this->sess = session_id();

    It looks like the plugin is creating an empty session just to set a cookie and get a unique token. But, no data is ever saved to the PHP session. The Rejoiner data is saved to a WP _transient_rjcart_[session token] row.

    @madjax: I would like to offer the following alternatives to creating empty PHP native sessions:

    1. Leverage WooCommerce’s internal cart/session to save this Rejoiner data;
    2. Or, if this is not a viable solution, then use setcookie() or wp_setcookie() to create a random cookie to act as your session token. You could also allow these cookie properties (name, domain, ttl, etc.) to be configurable in the plugin settings page.

    Either of these approaches would eliminate the dependency on native PHP sessions and would prevent the creation of thousands of empty sessions.

    I’m happy to assist or provide more clarity if you’d like.


Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jackson


    Thanks for the info, I’ll review and update you here.

    Is garbage collection not working on your server?

    Hey @madjax, garbage collection is working, but it’s configured with a 30 day TTL. In that time, we accumulate over 300k empty sessions. We’re using a memcache session store in php.ini, so these empty sessions just waste memory. I recently ran a job that cleared out these empty sessions, but then I realized that I’m breaking your plugin since session_start() will generate a new session/cookie if it is not found in memcache.

    I think using your own cookie with wp-admin configurable options, or piggy-backing on WooCommerce’s internal cart/session should be a better approach.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.