Sorry if this has been asked elsewhere, but I can't find the answer.
I recently made a site for which I've made significant use of session variables for the first time. I've never bothered to adjust the PHP session configuration before because it hasn't been necessary, session variables have worked as desired. For this site, I wanted to control the lifetime of sessions, so I needed to adjust gc_maxlifetime
. As there seems to be no 0 or off setting, I have set it to 31536000 (365 days) with the intention of controlling expiry using PHP script.
I'm setting gc_maxlifetime
via a local php.ini file, which my host allows. I'm also setting save_path
via this file as gc_maxlifetime
doesn't seem to work if it's not set. I presume this is because when save_path
has no value a default /tmp
folder for all users (this a shared server) is used and therefore you shouldn't be able to adjust the lifetime for all users.
And this all seemed to be working fine. I had two save locations, one for the main site and one for the CMS, at /absolute/hosting/path/tmp/session
and /absolute/hosting/path/tmp/session/admin
, phpinfo showed the correct values, and looking in the relevant folders I could see a bunch of session files. However, after a week or two (I don't exactly how long) the session functionality of my site stopped working altogether. New sessions were not being created at all. To fix it I have resorted to removing the save_path
from my php.ini file, but now my sessions only last the default 24 minutes.
My initial thoughts were that there might be some file or folder size restrictions within the /tmp
folder, but I wouldn't have a clue how to change that (presumably it would be an Apache thing that I'd need my hosting company to change), and it doesn't make much sense anyway, the files are small (1997 files, 17KB for the main site, 41 files, 9KB for the CMS), and the CMS carried on working for a week or so after the main site, before failing in the same way.
Does anyone have any idea what the cause of this might be?