0

I have a website hosted on CPanel (HostGator) written in PHP. I want my session to stay alive. For now, it seems to be cleared after about one hour. I have tried to set session.gc_probability = 0; in php.ini and just to make sure, I also do ini_set('session.gc_probability', 0); before starting my session. But still, the session gets cleared after about one hour, and there are no errors in error_log. I also tried to set a huge session.gc_maxlifetime and it also does not change the time before the session gets cleared.

I can see on CPanel on the module MultiPHP INI Editor that my settings are well set. I don't understand why the session gets always cleared after about one hour. Should I try to delete the sessions files on the filesystem?

  • I found that I should add the cookie `session.cookie_lifetime` as well with `session.gc_maxlifetime` to make sure the cookies of the session don't expire on the client side (Reference: https://stackoverflow.com/questions/6360093/how-to-set-lifetime-of-session). But still, my session gets cleared after one hour... really don't know why. – Gabriel Beauchemin-Dauphinais Dec 20 '22 at 17:47

0 Answers0