Home > Article > Backend Development > SESSION expiration setting in PHP
Due to project needs, some data must be saved in SESSION in PHP, but there is always an expiration that cannot be processed. Here is an introduction to the session expiration settings. If the session expiration is set to be invalid, please see the following solutions:
In PHP, set php.ini and find session.gc_maxlifetime = 1440 #(PHP5 default 24 minutes)
Here you You can set the expiration time at will. But some people say that after setting it, it doesn’t seem to work!
In fact, it’s not that it doesn’t work, but because the system defaults:
session.gc_probability = 1
session.gc_divisor = 1000
garbage collection has a probability Yes, 1/1000 means that the session is recycled only once in 1000 times.
As long as your traffic volume is large, you can achieve the recycling effect.
Otherwise you can also set Check the value of session.gc_divisor,
For example: session.gc_divisor = 1, so that you can clearly see the effect of SESSION expiration.