No action on the page, automatic exit after 5 minutes

Source: Internet
Author: User
I want to let the user logged in the system, if there is no action within 5 minutes, will automatically exit the system. How can we solve this problem?
How to judge the page is not action?


Reply to discussion (solution)

Make a checklogin.php page
Inclde this page in a page that needs to determine whether to timeout

Session_Start ();
Header ("content-type:text/html; Charset=utf-8 ");
Time-out, unit: seconds, set to 10 minutes.
$timeout = 600;
$now =time ();
if (($now-$_session[' session_time ') > $timeout)
{
Timed out.
unset ($_session[' ClientID ');
}
Else
{
It hasn't timed out yet.
$_session[' Session_time ']=time ();
}
if (Empty ($_session["ClientID"]))
{
echo "";
Exit
}

I want to let the user logged in the system, if there is no action within 5 minutes, will automatically exit the system. How can we solve this problem?
How to judge the page is not action? So how do you tell the user is logged in?

Login successful users, put the user name in the session, and then you can see the session there is no data, if not on the implementation of automatic exit system

Make a checklogin.php page
Inclde this page in a page that needs to determine whether to timeout

Session_Start ();
Header ("content-type:text/html; Charset=utf-8 ");
Time-out, unit: seconds, set to 10 minutes.
$timeout = 600;
$now =time ();
if (($now-$_session[' session_time ') > $timeout)
{
Timed out.
unset ($_session[' ClientID ');
}
Else
{
It hasn't timed out yet.
$_session[' Session_time ']=time ();
}
if (Empty ($_session["ClientID"]))
{
echo "";
Exit
}

---------------------------------------
You can only call this method manually to detect if the time set in the session expires.
What I want is: if I log into the system, will maintain a user ID in the session, when I do not do any action in 5 minutes, the system will think I do not need to operate, will automatically disconnect.
You do this, after 10 minutes. Regardless of whether I force delete session in the operation, the system will be launched


I want to let the user logged in the system, if there is no action within 5 minutes, will automatically exit the system. How can we solve this problem?
How to judge the page is not action? So how do you tell the user is logged in?
-------------------------------
I log in when the cookie or the session to save a user ID, I want to implement like phpMyAdmin, log in 1440 seconds after the login without action to disconnect. How can I tell if the page is not currently in action?

The connection itself is already disconnected.

You add a login time variable to a cookie or to a session
He's visiting again to judge.

The connection itself is already disconnected.

You add a login time variable to a cookie or to a session
He's visiting again to judge.
---------
If I stop at page a now. I'm going to make a phone call, I'll be back in half an hour, and I'll click on the item on page A to determine if it's expired by comparing the time in the session.

Yes, that's it.

Yes, that's it.
---
Moderator, add me qq 1587232556, I still do not understand, want to ask you to explain to me under.

Take the session as an example
At logon
$_session[' userid '] = $userid;
$_session[' time ' = time ();

When you enter again
if (Time ()-$_session[' time ') > 1440) {
Timeout processing
}else{
$_session[' time ' = 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.