PHP Session Survival time problem, ask for help

Source: Internet
Author: User
Here are the a.php and b.php two files php.ini settings session.gc_maxlifetime equals 1


Access A.php After the session is generated and then access the b.php over 1 seconds, 5 seconds, 10 seconds to visit b.php why b.php inside the session has always been worth it? Why hasn't it expired?


Reply to discussion (solution)

Session.gc_maxlifetime indicates that SessionID can be deleted after the last access session.gc_maxlifetime seconds
Note: Can be deleted, not necessarily deleted
Whether or not to be deleted depends on the ratio of session.gc_probability/session.gc_divisor
PHP Default:
session.gc_probability = 1
Session.gc_divisor = 1000
That is, the probability of being deleted is 1 per thousand.

Also on some servers, if Session.save_path points to a temporary file directory that is not the operating system, the GC process will not function to his
Session temp file will persist until you manually clean up the garbage

Session.gc_maxlifetime indicates that SessionID can be deleted after the last access session.gc_maxlifetime seconds
Note: Can be deleted, not necessarily deleted
Whether or not to be deleted depends on the ratio of session.gc_probability/session.gc_divisor
PHP Default:
session.gc_probability = 1
Session.gc_divisor = 1000
That is, the probability of being deleted is 1 per thousand.

Also on some servers, if Session.save_path points to a temporary file directory that is not the operating system, the GC process will not function to his
Session temp file will persist until you manually clean up the garbage


The original is so, thank you very much!
There is also a problem is not very clear, SessionID can be shared, that is how to kick the user offline?

How to set a session with a strict 30-minute expiration date

Theoretically, SessionID cannot be shared.
Because SessionID is passed through a cookie and is valid for 0

Kick the user offline, generally need to use a custom session operation

  • 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.