NeoTrix
NeoTrix

Reputation: 144

CodeIgniter: Sessions aren't being cleared from 'ci_sessions` table

I'm having a little issue with my CodeIgniter setup. I configured CodeIgniter to save & store the sessions in the ci_session table in the Database. As I've read a little about it, I understand that every time the session library loads it should clean the table in the DB for old sessions. Today I accessed my DB and I saw that the table is already containing 600 sessions, when It's only me & friend developing the system and there are no other users that accessing the pages, and after sorting in the DB the timestamp column I saw that it stored records from the 5th of October.

I want it to clear the old sessions of course.

Here's my configuration of the session from config.php file:

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 86400;     // Default: 7200
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Please advise.

Thanks, Slavik.

Upvotes: 4

Views: 2756

Answers (1)

Federkun
Federkun

Reputation: 36999

Until the garbage collection kicks in, the expired sessions are not deleted. It is called randomly, and the frequency is based on the session.gc_divisor and session.gc_probability parameters.

If you want to happen as soon as possible, you should decrease session.gc_divisor.

Upvotes: 2

Related Questions