CodeIgniter Forums

Full Version: [Solved] Files-Sessions spam
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I noticed today that my server was running low on space, upon investigation I found 40GB worth of session files in the sessions directory. I tried a few settings in the config to make it stop, but it insists on creating 100mb worth of sessions every minute and I do not know why. I hesitate to switch to database sessions because once that space is used its not freeing up again. Feel like this is a known issue or just something I forgot to check, but my google-foo is failing me. How do I stop this spamming before my drive is full?

This is the config.php session section:


Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = '/var/lib/php/sessions/weatheros/';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;
If you're running Debian (or another distribution based on it), set this in your php.ini:

Code:
session.gc_probability = 1
That didn't seem to do anything in this case, but I did figure it out eventually.

Basically I had the session library loaded in a controller that really only does one thing, output database data to a page based on the id in the database. Somehow that caused a session to be created every time the page was called, why is beyond me, but after removing the session library from load in that controller the spamming stopped. The library isn't even used, nothings done with sessions in the only view it handles and the only model function it uses does not use the sessions either. While I would like to know what could cause this I would consider this solved now.
(08-21-2017, 01:20 AM)Tampa Wrote: [ -> ]That didn't seem to do anything in this case, but I did figure it out eventually.

Basically I had the session library loaded in a controller that really only does one thing, output database data to a page based on the id in the database. Somehow that caused a session to be created every time the page was called, why is beyond me, but after removing the session library from load in that controller the spamming stopped. The library isn't even used, nothings done with sessions in the only view it handles and the only model function it uses does not use the sessions either. While I would like to know what could cause this I would consider this solved now.

The session_start() in the New Session Library, starts a new session every time, which creates a new session file. This is unlike 2.x or 1.x, so I'm not sure how to fix this. I struggle with the same situation.