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

  • Resolved adamchal

    (@adamchal)


    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.

    Thanks,
    Adam

Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Remove session_start() Dependency’ is closed to new replies.