Home  >  Article  >  Backend Development  >  SESSION expiration setting in PHP

SESSION expiration setting in PHP

巴扎黑
巴扎黑Original
2016-11-11 15:15:12965browse

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn