Ask, your session has expired please re-login?

Source: Internet
Author: User
This post was last edited by u010572351 on 2013-06-29 18:34:28

I do a simple user login system to realize that your session has expired please re-login this feature:

1. Landing page, the user first landing, and now certainly what hints should not have.

2. The user login success, the corresponding page, and soon the session expired, forced to jump to the landing page, but also prompted a word to the user: your session has expired please re-login, this How to achieve AH?


Reply to discussion (solution)

$_seesion

$_seesion

....... I know it's the session, I mean, how does this logic go?

Http://hi.baidu.com/liang_1989/item/89706bc7068d3274ced4f8d5

You can set the length of time the cookie expires.

Session sets the expiration time of the user ID. Setting a cookie to fail is often used to determine user page jumps

http://fushidian.blog.163.com/blog/static/567656992010102522713846/

Upstairs set sesion time should not be able to achieve the landlord's purpose, because the value is not the same as no login status, and can not be detected, you may set a variable in the SESSION to save time, such as $_session[' exptime '] = Now () +3600 To specify a time-out after 3,600 seconds, and then check the login status to determine if $_session[' exptime ' is greater than now () to make a judgment!

I think it should not be detected in the login location. Should be detected at the next operation,
Log in after completion of the next time, such as 10 minutes to deposit $_session[' Exptime ' =now () +600
Then each action is to detect whether the login status
Like what

if (!isset ($_session[' username ')) | | $_session[' username ']) {

$_session[' tips ']= "";
。。。 Jump Login Page
}else{
if ($_session[' Exptime ')
$_session[' username ']= "//Clear off the original state
$_session[' tips ']= "Your session has expired please re-login";
。。。 Jump Sign-in page: and output $_session[' tips ']
}

}
$_session[' Exptime ']= finish () +600;
Reset $_session[' Exptime ' after detection is complete

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