Reputation: 3605
I am sometime experiencing the following issue with CodeIgniter:
ERROR - 2019-03-05 19:57:26 --> Severity: Warning --> session_start(): Failed to decode session object. Session has been destroyed /system/libraries/Session/Session.php 143
This error appears in my server log and is impossible to artificialy replicate.
I already read the following SO questions:
I also asked on the CodeIgniter forum, but I didn't have any answer.
https://forum.codeigniter.com/thread-72960.html
Here are my session configuration (in application/config/config.php
)
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
Any ideas what could be the roots of that problem and/or where to start ?
Upvotes: 5
Views: 15329
Reputation: 181
I encountered this error when using the database option to store session information. 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.
Upvotes: 18
Reputation: 3605
In application/config/config.php, set this value:
$config['sess_save_path'] = sys_get_temp_dir();
Upvotes: 3
Reputation: 8964
The problem is with this setting
$config['sess_save_path'] = NULL;
When using the "files" driver, which you are, as determined by the following
$config['sess_driver'] = 'files';
$config['sess_save_path']
must be set to the absolute path where the session files will be stored. e.g.
$config['sess_save_path'] = '/var/www/project/sessions/';
When set to NULL all kinds of weird and unpredictable things happen. The folder must also have appropriate ownership and permissions.
Upvotes: 5