How can I solve this problem by setting the session validity period code of the administrator account in PHP?

Source: Internet
Author: User
Tags php session
Ask for the PHP code to set the validity period of the session of the administrator account. for example, after the administrator logs on, the session becomes invalid if the page is not refreshed for 10 minutes. when requesting the page again, he needs to log on again. ------ Solution ------------------ use session to record the last logon time as the current time. Compare the current time-last logon time with 10 minutes. If the value is greater than 10 minutes, the session is destroyed. Otherwise, update sessi and request PHP to set the validity period code of the session of the administrator account.
For example, if the session becomes invalid 10 minutes after the administrator logs on to the page, he or she needs to log on again when requesting the page again.

------ Solution --------------------
Use session to record the last logon time as the current time. Compare the current time-last logon time with 10 minutes. If the value is greater than 10 minutes, the session is destroyed. Otherwise, the session is updated to the current time.
------ Solution --------------------
Write cookie
------ Solution --------------------
Php session should be 1440 s by default, that is, 24 min

You can modify it from php. ini.
You can also write it like this.
Session. gc_maxlifetime = "600"; // Here is the valid time


------ Solution --------------------
Discussion

Php session should be 1440 s by default, that is, 24 min

You can modify it from php. ini.
You can also write it like this.
Session. gc_maxlifetime = "600"; // Here is the valid time

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.