Php background to determine whether a user has any operations

Source: Internet
Author: User
In many background management systems, such a function is set to determine that the user has not performed the operation for a period of time, and then exit.

In many background management systems, such a function is set to determine that the user has not performed the operation for a period of time, and then exit.

Today, I wrote this function, and I will record it and share it with you.

1. first, set a COOKIE or SESSION value at the logon location and set its validity period. for example, if you use a COOKIE,

1
Setcookie ('name', $ value, $ time );

2. check whether the value exists at the entrance of the website. If yes, assign the same value to the variable again. if no value exists, you can jump to the logon page.

1
2
3
4
5
6
7
8
9
10
11
If ($ _ COOKIE ['name']) {

Setcookie ('name', $ value, $ time );

}

Else {

Header ('Location :/');

}

This is just an example. you can refer to it and welcome your suggestions or comments.

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.