Support » Plugin: WordPress Native PHP Sessions » session already active dont create session ID

  • Steve

    (@stegster)


    Thanks for creating this plugin, it has helped me get a plugin working, although i am getting an error message in the debug log. The error doesn’t seem to be causing any issues though as the plugin is creating the session in the database.

    I was just wondering, on line 39 in callbacks.php, if i comment out this code the error goes away.
    line 39 –
    session_id( md5( $hasher->get_random_bytes( 32 ) ) );

    My question is, am i breaking anything by doing this or is there a safer way as opposed to commenting the line out?

    I tried writing an if statement

    if (!session_id()) {
         session_id( md5( $hasher->get_random_bytes( 32 ) ) );
    }

    However this doesn’t seem to stop the error message.

    Many thanks

    Stevan

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Hi @stegster,

    WP Native PHP Sessions should work without any code modifications. An error seems to indicate that something isn’t configured correctly.

    Just to confirm, have you activated the plugin as a mu-plugin? There’s more detail in this thread.

    Thread Starter Steve

    (@stegster)

    Hi Daniel,
    I think i found the plugin that was causing the error to appear but i tried activating as a mu plugin (as mentioned in the other thread) with no luck.

    The other plugin initialises the session like this –
    add_action( 'init', array( $this, 'start_session' ));

    and to start the session they have written it like this –

    public function start_session() {
    	    if(!session_id()) {
    	        session_start();
    	    }
    	}

    Not sure if that helps.
    This is the plugin in question – https://codecanyon.net/item/wpml-redirect-based-on-ip-country/18074869

    Thank you

    • This reply was modified 2 years ago by Steve.
    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Huh, that’s odd.

    Is this on a Pantheon site? If so, could you add me to the site in question so I can take a look? My email address is on my GitHub profile.

    Thread Starter Steve

    (@stegster)

    I’m afraid it isn’t.
    My server is based in-house and we have it setup with PHP 7.3 and Varnish.
    Thanks

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Ok. Unfortunately, the support I can offer is limited to this forum then. Let me know if you come across further questions in your debugging.

    Thread Starter Steve

    (@stegster)

    That’s totally understandable and thank you for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘session already active dont create session ID’ is closed to new replies.