[ACCEPTED]-session.gc_maxlifetime not working for me-php
Three variables are used to define the garbage 19 collection behavior of PHP session variables:
- session.gc_maxlifetime is the lifetime in seconds for the session files (default value: 1440 = 24 minutes)
- session.gc_probability is the nominator for the probability to execute the garbage collector (default = 1)
- session.gc_divisor is the denominator for the probability to execute the garbage collector (default = 100 or 1000)
The 18 nominator and denominator are used together 17 to determine the probability (nominator 16 / denominator). So when session.gc_probability 15 is 1 and session.gc_divisor 100 this is 14 1 / 100 = 1 %. So 1 % of every page visit 13 (= every session_start call) the garbage 12 collector is executed.
If you want to test 11 how your session expires, you need to set 10 session.gc_probability and session.gc_divisor 9 to 1, so each page visit will cause the 8 garbage collector to run. Furthermore you 7 need to use two different browsers for the 6 test. The session of the first browser becomes 5 cleaned when you visit your page with the 4 second browser (and the session of the first 3 browser is timed out). In my tests, when 2 you use only one browser, the session becomes 1 automatically extended although it is outdated.
The session will live as long as the file 9 is left on the server's file system. They 8 are cleaned out by a garbage collector. The 7 garbage collector is run approximately every 6 hundred page loads on the server (this is 5 rather random, the "every hundred" page 4 loads is just an average).
Also, the age 3 of the session is inactive age, not total age. The 2 timer will be reset for that session every 1 time the user does a request.
The unit for the session.gc_maxlifetime value is seconds. So you 5 would need to set it to 180
seconds to express 4 3 minutes.
But besides that, session.gc_maxlifetime is not reliable 3 (see this post for an explanation). You should better 2 implement that on your own to have your 1 session expired after exactly 3 minutes.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.