Title: Session data getting wiped out randomly
Last modified: March 23, 2022

---

# Session data getting wiped out randomly

 *  [acurran](https://wordpress.org/support/users/acurran/)
 * (@acurran)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/session-data-getting-wiped-out-randomly/)
 * 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 4 years, 2 months ago by [acurran](https://wordpress.org/support/users/acurran/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/session-data-getting-wiped-out-randomly/#post-15500619)
 * Hey [@acurran](https://wordpress.org/support/users/acurran/),
 * Here’s a [Stack Overflow thread that seems relevant](https://stackoverflow.com/a/60994925/6800777):
 * > 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”](https://github.com/pantheon-systems/wp-native-php-sessions/releases/tag/v1.2.4).
 * 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](https://wordpress.org/support/users/acurran/)
 * (@acurran)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/session-data-getting-wiped-out-randomly/#post-15500724)
 * Hi [@danielbachhuber](https://wordpress.org/support/users/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 Contributor [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * (@danielbachhuber)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/session-data-getting-wiped-out-randomly/#post-15504417)
 * 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.

 * ![](https://ps.w.org/wp-native-php-sessions/assets/icon-256x256.png?rev=3411177)
 * [Native PHP Sessions](https://wordpress.org/plugins/wp-native-php-sessions/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-native-php-sessions/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-native-php-sessions/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-native-php-sessions/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-native-php-sessions/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-native-php-sessions/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Daniel Bachhuber](https://wordpress.org/support/users/danielbachhuber/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/session-data-getting-wiped-out-randomly/#post-15504417)
 * Status: not resolved