CodeIgniter Forums
CI4 sessions still not being deleted - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: CI4 sessions still not being deleted (/showthread.php?tid=75894)



CI4 sessions still not being deleted - Fido L Dido - 03-27-2020

I've read the other threads on session files not being cleaned up on CI4. I am suffering the same issue, with hundreds of session files when it is only me accessing the site.

I've checked which php.ini file apache is using and have set the following values:
Code:
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440

I've also located all other php.ini files and set the same values. I've checked my syslog and it does appear that php/sessionclean is running periodically. Beyond writing my own cleanup routine I'm at a bit of a loss as to how to fix this or even go about debugging what might be going wrong?


RE: CI4 sessions still not being deleted - dave friend - 03-27-2020

Using 1/1000 can result it quite a large build-up of old sessions. Try these settings for a while to see if things get cleaned up.

Code:
session.gc_probability = 1
session.gc_divisor = 2
session.gc_maxlifetime = 1440

Those values are only temporary to see if GC will happen. If the extreme 1/2 doesn't work then you can be certain that something is wrong. If it does work you can settle on a more reasonable set of values.

Code:
session.gc_probability = 1
session.gc_divisor = 100

The php/sessionclean you are seeing in the log might be a CRON job that is scanning some directory other than the one you have set up for CodeIgniter to use. In other words, it's not directly related to PHP/SESSION garbage collection.


RE: CI4 sessions still not being deleted - Fido L Dido - 03-27-2020

(03-27-2020, 07:16 AM)daveĀ friend Wrote: Using 1/1000 can result it quite a large build-up of old sessions. Try these settings for a while to see if things get cleaned up.

Code:
session.gc_probability = 1
session.gc_divisor = 2
session.gc_maxlifetime = 1440

Thanks Dave, I'll give that a go and report back. I've just 'done the maths' on my current settings and realise it equates to a clearout on average every 16-17 days, and I've only have a weeks worth of data. I may have been a little premature.