Questions about the session garbage collection mechanism

Source: Internet
Author: User
About the session garbage collection mechanism! Seession. gc_maxlifetime1440; seesion. gc_probalility1; session. gc_divisor1000; in my understanding above, sessions can be used only by users with one thousandth point. but if the probability is one thousandth point, it is wrong. how does the session work ?? Please give me a satisfactory explanation .. ------ Solution-about the session garbage collection mechanism!

Seession. gc_maxlifetime = 1440;
Seesion. gc_probalility = 1;
Session. gc_pisor = 1000;

In my understanding above, sessions can be used by users with one thousandth point. However, if the probability is one thousandth point
That's wrong. how does the session work ?? Please give me a satisfactory explanation ..

------ Solution --------------------
An explanation of the reference:
The principle of PHP session processing is no exception, but the specific implementation method is different. This is because, due to the working mechanism of PHP, it does not have a background thread to regularly scan session information and determine whether it is invalid. The solution is that when a valid request occurs, PHP determines whether to call a GC (Garbage Collector) based on a probability ). GC is to scan all session information, and subtract the current time from the last modification time (modified date) of the session, which is the same as the configuration option session. compare the value of gc_maxlifetime. if the survival time exceeds gc_maxlifetime, delete the session. This is easy to understand, because if the GC code is called every time a request is made, PHP's efficiency will be much lower. This probability depends on the value of the configuration parameter session. gc_probability/session. gc_pisor (which can be modified through the php. ini or ini_set () function ). By default, session. gc_probability = 1, session. gc_pisor = 100, that is, there is a 1% possibility to start GC.
The three parameters, session. gc_maxlifetime/session. gc_probability/session. gc_pisor, can be modified through the php. ini or ini_set () function. Remember that if you use the ini_set () function, you must call ini_set () at the beginning of each page ().


Read Full Text: http://koda.iteye.com/blog/319605

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.