0

When i do not use keyboard and mouse for a particular time limit (Like 10 min or 20 min) at that time it should log out User automatically from the current session. Please give me any suggestion or code in PHP.

  • Please describe how your login system works. With cookies? – hek2mgl May 03 '13 at 04:46
  • Probably you are looking for this solution: [http://stackoverflow.com/questions/15966686/auto-redirect-after-no-user-action][1] [1]: http://stackoverflow.com/questions/15966686/auto-redirect-after-no-user-action – Santosh Panda May 03 '13 at 04:55

2 Answers2

0

You need javascript to detect browser events.

With jQuery, something like (untested)

var timeSinceLastMove = 0;

$(document).mousemove(function() {

    timeSinceLastMove = 0;
});

$(document).keyup(function() {

    timeSinceLastMove = 0;
});

checkTime();

function checkTime() {

    timeSinceLastMove++;

    if (timeSinceLastMove > 10 * 60) {

        window.location = "path/to/logout.php";
    }

    setTimeout(checkTime, 1000);
}
Steve Robbins
  • 13,672
  • 12
  • 76
  • 124
0

you must set the session timeout in your code

session_set_cookie_params(3600); // sessions last 1 hour session_start(); // do this after setting the params

cafebabe1991
  • 4,928
  • 2
  • 34
  • 42