CodeIgniter Forums
Remove files the sessions - 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: Remove files the sessions (/showthread.php?tid=63925)



Remove files the sessions - edica - 12-23-2015

Hello,

About removing files in the folder sessions? How is it done automatically? Here it is not working. The sessions folder is big.

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 2000;
$config['sess_expire_on_close'] = FALSE;
$config['sess_save_path'] = FCPATH.'application/sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

Thanks.


RE: Remove files the sessions - mwhitney - 12-29-2015

Copying/pasting from http://forum.codeigniter.com/thread-63565-post-325590.html#pid325590

PHP should automatically cleanup old sessions (regardless of which driver you use) based on the settings session.gc_probability, session.gc_divisor, and session.gc_maxlifetime, usually set in php.ini (but it can be set elsewhere, if needed).

Some Linux installations (especially Debian-based distributions like Ubuntu) set these variables so the built-in garbage collector won't run, then add their own cron job to do it every 30 minutes or so. The only problem with that is that you probably aren't using the default location for session data, so you would have to either change the settings or create your own cron job to perform the garbage collection.


RE: Remove files the sessions - edica - 01-11-2016

I use Ubuntu. How do I create cron job? I have no idea.