CodeIgniter Forums
Session Files Question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Session Files Question (/showthread.php?tid=66055)



Session Files Question - wolfgang1983 - 08-29-2016

My sessions create a new file OK.

How every if there are any old session files Question do they get deleted automatic at certain time.

Because I do not want to get my session cache folder full.

Thank you.


RE: Session Files Question - dave friend - 08-31-2016

Do not worry. It will not get full. The "garbage" (old session files) will automatically be removed periodically.
How often this happens depends on the PHP.ini settings session.gc_probability and session.gc_divisor.
Read about these settings here. The default values are usually just fine.

The garbage collector is triggered when the session library is loaded.


RE: Session Files Question - wolfgang1983 - 09-16-2016

(08-31-2016, 07:43 AM)daveĀ friend Wrote: Do not worry. It will not get full. The "garbage" (old session files) will automatically be removed periodically.
How often this happens depends on the PHP.ini settings session.gc_probability and session.gc_divisor.
Read about these settings here. The default values are usually just fine.

The garbage collector is triggered when the session library is loaded.

What about if I use database instead does it delete old sessions from database in time like files garbage?


RE: Session Files Question - Diederik - 09-16-2016

Yes, the same garbage collector should kick in to remove old session data from the database.

But be aware if you setup a VPS on your own instead of using services from a webhosting company. Some linux distro's, like Debian for example, ship with the default settingConfusedession.gc_probability = 0. Wich mean that php will not run the garbage collection stuf. Debian's philosophy here comes from a security point of view that old sessions should be destroyed with a cronjob instead of by a php instance. Just some side info to keep in the back of your mind.