Questions about the garbage collection mechanism of the session

Source: Internet
Author: User
About the session garbage collection mechanism problem!

seession.gc_maxlifetime=1440;
Seesion.gc_probalility=1;
session.gc_divisor=1000;

I understand that 1 of thousands of users may use the session, but if it is the probability of a 1-percent
, that's not right, the session how to do ah?? To ask for a satisfactory explanation.

------Solution--------------------
An explanation of the quote:
The principle of PHP processing session is no exception, but in the specific way of implementation, but different. This is because, because of PHP working mechanism, it does not have a background thread, to periodically scan the session information and determine whether it is invalid. The solution to this is that when a valid request occurs, PHP determines whether to invoke a GC (garbage Collector), depending on the probability. The GC's job is to scan all session information, subtracting the last modification time of the session (modified date) with the current time, with the configuration parameter (config option) session.gc_ The Maxlifetime value is compared, and if the lifetime has exceeded Gc_maxlifetime, the session is deleted. This is easy to understand, because if the GC code is called every time the request is made, PHP will be inefficient. This probability depends on the value of the configuration parameter Session.gc_probability/session.gc_divisor (which can be modified by the php.ini or Ini_set () function). By default, session.gc_probability = 1,session.gc_divisor=100, which means that there is a 1% possibility to start the GC.
These three parameters, Session.gc_maxlifetime/session.gc_probability/session.gc_divisor can be modified by the php.ini or Ini_set () function. Remember, however, that if you use the Ini_set () function, you must call Ini_set () at the beginning of each page.


Read the 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.