Answer the question
In order to leave comments, you need to log in
Why does the session end while working with the site?
Hello. Sometimes the session of my users ends right while using the site, especially the more visitors, the more often the user is sent for authorization. It doesn't even depend on the time set in php.ini. At the same time, on every session_start() page, and even every second, a script is called via AJAX, which also has session_start(). I don't use any functions to end sessions. What are the reasons for a session to end?
Answer the question
In order to leave comments, you need to log in
At first glance, some (or one) php scripts are launched with their own small gc_maxlifetime value. And the more people, the more often this script is launched and the session files that it considers obsolete are erased.
Somehow this assumption needs to be tested.
1. Set a different directory for the site to store sessions. See if the problem is still there. If it is gone, then there are some other php scripts that delete session files.
2. First, check with your eyes whether there is a redefinition of gc_maxlifetime before session_start () in all site scripts. If nothing is found, you can move the work with sessions to a separate class and temporarily log the session settings somewhere when working with it. Perhaps - there are guilty scripts that are part of the site.
And, just in case, what are the values of the following settings at runtime?
var_dump(ini_get('session.cookie_lifetime'));
var_dump(ini_get('session.gc_maxlifetime'));
var_dump(ini_get('session.gc_divisor'));
var_dump(ini_get('session.gc_probability'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question