I am on a shared host (OVH pro) using Laravel 5.2 on production (PHP 7.0.5).
I am using the file session driver, and everything was working fine on my previous host (with the same app), but since I moved to OVH, the session files keep being created and are never deleted by the PHP garbage collection. I have to manually erase the files (over 5000 files are created per day).
My config/session.php
file is set up correctly:
'driver' => 'file',
'lifetime' => 120,
'lottery' => [2, 100],
And my folders storage
, storage/framework
, storage/framework/sessions
are all set with a 0755 permission.
I also override the php.ini by placing those 2 lines at the top of config/session.php
ini_set('session.gc_probability', '5');
ini_set('session.gc_divisor', '100');
It seems to be working fine from what phpinfo()
returns:
I contacted my host, but they told me it must have to do with my Laravel app, and they can't help.
Edit: My sessions work fine, I mean that there's only one file created per visitor. The problem is only the fact that the session files are not getting cleaned up, even with a 777 permission.
Even when I put the Laravel session lottery to 100/100, the files are still not getting deleted:
/*
|--------------------------------------------------------------------------
| Session Sweeping Lottery
|--------------------------------------------------------------------------
|
| Some session drivers must manually sweep their storage location to get
| rid of old sessions from storage. Here are the chances that it will
| happen on a given request. By default, the odds are 2 out of 100.
|
*/
'lottery' => [100, 100],
EDIT: OVH hosting specifics:
I use multisites on OVH, and the folders containing each site are placed at the route of my OVH host, and not in the default www
folder.
I did that for security reasons, because the www
folder is publicly available through mynickname.cluster005.ovh.net
and I dont want any of my sites to be publicly available from
mynickname.cluster005.ovh.net/site1
mynickname.cluster005.ovh.net/site2
...
(www\site1
, www\site2
...).
So I was thinking that maybe only the files located inside www
folder are writable, and maybe not the one outside (at the root)? That would explain while my files are not being deleted. I'll make a test tonight to see if the files are being deleted when placed in www\site1\storage\sessions
.