Click here to Skip to main content
16,017,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Am developing an entertainment site and it no activity happens from the user side how i can redirect the page or make it automatically logout after 20min if user is not performing any kind of action on it .

Is there any function that can make it happens?
Posted

You can use javascript setTimeout for calling a function after 20 min and you can write your code like the following. 20000 means 20 minutes and it will be in millisecond. Or you can use javascript
setInterval for calling a function after 20 min. You can add this setinterval and settimeout function in document.ready function of jquery or yoou can use it anywhere.

setTimeout("MethodToCall()", 20000);

window.setInterval(MethodToCall, 20000);

function MethodToCall()
{
...
//
..
}

And check the idele time like the following

C#
var delay = 30; //seconds
    var userTimeExpired;
    var IDLE_TIMEOUT = 30; //seconds
    var idleSeconds = 0;
    document.onclick = function () {
        idleSeconds = 0;
    };
    document.onmousemove = function () {
        idleSeconds = 0;
    };
    document.onkeypress = function () {
        idleSeconds = 0;
    };
    window.setInterval(CheckIdleTime, 1000);

    function CheckIdleTime() {

        _idleSecondsCounter++;
        var popUpPanel = document.getElementById("scanCardchild");
        if (idleSeconds >= IDLE_TIMEOUT) {
           //Postback to new page here
        }
    }
 
Share this answer
 
v2
In 1997, I had to build a kiosk-based web application that would timeout and go back to the home page. I used a META tag within <HEAD> like this:

<META HTTP-EQUIV="Refresh" CONTENT="1200; URL=http://mywebsite.com/index.html">
 
Share this answer
 
v2
jquery-idletimer-plugin/[^]

Hope it will help you..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900