CodeIgniter Forums
CI Sessions config question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: CI Sessions config question (/showthread.php?tid=65197)



CI Sessions config question - mrosenello - 05-13-2016

Hey Guys,

I seem to have an issue with my Sessions config where it isn't doing what I am anticipating.  I am trying to set sessions to never expire; however, they all seem to expire within a few days.

I am using the database driver and the oldest timestamp on any ci_session record is ~5 days ago.  (the table has just over a million records in it currently).  Below is my settings and any insight would be much appreciated.

PHP Code:
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 157680000;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 157680000;
$config['sess_regenerate_destroy'] = FALSE;
$config['sess_use_database'] = TRUE



RE: CI Sessions config question - skunkbad - 05-13-2016

1) sess_time_to_update has nothing to do with how long the session is supposed to last, so you should reset that value.

2) sess_use_database will have no effect in CI 3.0.

3) Everything else looks right, and that your sessions should last 5 years.

4) If it's not a bug in your code, then perhaps a bug in CI's garbage collection?


RE: CI Sessions config question - mrosenello - 05-13-2016

Thanks for the help. I'm not cleaning up any old sessions in my code (that I know of).

Also thanks for the help on those other settings, I knew they were kind of a mix from CI 2. and 3. I will clean those up.

Any idea where the CI garbage collection happens? I'm curious to have a look through it.


RE: CI Sessions config question - skunkbad - 05-13-2016

For the database driver, garbage collection is done in the gc method, near line 330 of system/libraries/Session/drivers/Session_database.php