Is CodeIgniter generating too many sessions files?
At Bobcares, we resolve similar queries as a part of our Server Management Services.
Our Support Team is here with a quick fix to empty out the /tmp folder and delete those additional sessions files.
What is CodeIgniter?
Before we delve into resolving this issue, let’s take a look at CodeIgniter. It is a PHP framework used to develop applications. CodeIgniter offers box libraries to connect to the database to perform several operations like uploading files, sending emails, managing sessions and so on. Furthermore, it offers several advantages like:
- Hassle-fee migration
- User-friendly interface
- Quick development
- MVC based system
- Better SEO
About CodeIgniter generating too many sessions file>
Recently, one of our customers approached us with an issue where the disk space on /tmp had filled up. Our Support Engineers investigated the issue. After that, we soon discovered that the CodeIgniter application had created too many cl_sessions files in the server tmp folder. In other words, the sessions files were piling up in the /tmp folder.
How to resolve CodeIgniter generating too many sessions files
To resolve this, the sessions files were removed automatically by adding the following entries to the php.ini file:
session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440
Moreover, in order to ensure that the issue did not arise again, our Support Techs also verified that regenerate_destroy and expiration were enabled in the CodeIgniter configuration file. For instance:
onfig['sess_driver'] = 'files'; $config['sess_cookie_name'] = ‘mysession'; $config['sess_expiration'] = (60 * 60); $config['sess_save_path'] = FCPATH . "sessions"; $config['sess_match_ip'] = FALSE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = TRUE;
Our Support Techs would also like to point out that you will not be able to delete the files if gc_probability value is 0. In other words, set it to 1 to enable automatic file deletion.
With these changes, you will be able to put a stop to CodeIgniter generating too many sessions files.
[Looking for further assistance? Give us a call today. ]
At the end of the day, the skilled Support Team at Bobcares demonstrated how to easily automatically delete additional sessions generated by CodeIgniter.