• In my web application I have noticed the session data getting wiped out randomly/intermittently. When this happens there is a PHP warning msg: ‘Warning: session_start(): Failed to decode session object. Session has been destroyed in ….’.
    I’m wondering this issue could be connected to this plugin. Any ideas?

    I’m using latest version of WP (5.9.2) and WordPress Native PHP Sessions (1.2.4).

    In my code I check session id and initiate a session if there is none:

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

    This is triggered by the init hook.

    • This topic was modified 2 years, 8 months ago by acurran.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Hey @acurran,

    Here’s a Stack Overflow thread that seems relevant:

    When using this option, CodeIgniter stores session data in a table called ci_sessions, specifically in the ‘data’ column. By default, CodeIgniter creates this column as a blob datatype which has a maximum data size of 65,535 bytes. My application was exceeding that size and throwing the error. To remedy the issue, I changed the datatype to mediumblob which has a maximum size of 16,777,215 bytes. Afterwards, my application no longer generated the error and worked as expected.

    In WP Native PHP Sessions v1.2.4 (released September 2021), we “increase[d] data blob size from 64k to 16M for new session tables; existing tables will need to manually modify the column if they want to apply this change”.

    My guess would be that your session blob is exceeding the size supported by the column, and you’ll need to manually alter your database column.

    Hope this helps!

    Thread Starter acurran

    (@acurran)

    Hi @danielbachhuber,
    Interesting, and it could possibly be related to this.

    However, I did a test to see what happens when the session data exceeds 64k and I found that the error message was different. I did not get Warning: session_start(): Failed to decode session object. Session has been destroyed in …. Instead I got:

    Notice: Undefined index: debug in /path/to/my/file.php on line xxx
    
    Notice: Trying to access array offset on value of type null in /path/to/my/file.php on line 450

    So, I’m not sure if the issue is due to exceeding the blob size limit but I’ll switch the column to use type mediumblob and see if it makes any difference.

    Thanks, Aidan

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Sounds good! Let us know what you find.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Session data getting wiped out randomly’ is closed to new replies.