Overdue sessions are not actually destroyed immediately after 24 minutes. Here's how it happens: at the beginning of each request that uses the session (due to a prior call of the session_start () function or setting session / auto_start to on ), there is a 1% chance that the PHP interpreter will scan all the sessions on the server and remove any of the expired ones. “1% of opportunity” for a computer program sounds completely unpredictable. The way it is. But such unpredictability improves overall performance. An intensively working site, busy at the start of each request, searching for expired sessions to remove them, will use up too much server resources.
The session.gc_maxlifetime configuration directive controls the setting of the maximum idle time between requests, during which session activity is maintained. Its default value is 1440 - just as many seconds in 24 minutes. It is possible to change the value of session.gc_maxlifetime either by setting the server configuration, or by calling the ini_set () function directly from the program. The call to this function must take place before the call to the session_start () function.
Do not rely on the 1% probability if you wish to delete an overdue session for sure. The configuration directive session.gc_probability sets the percentage of the probability of launching the subroutine “delete obsolete sessions” at the beginning of processing a request. To start this process at the beginning of processing each request, the directive value is set to 100. Also, as in the case of session.gc_maxlifetime , the call to ini_set () to change the value of session.gc_probability must occur before the call to the session_start () function.
gc_probability = 1The probability is already not 1%, but 0.1% .
gc_divisor = 1000
Source: https://habr.com/ru/post/13248/
All Articles