To verify that the user has not done anything, you can monitor events that mean user interaction:
var last_seen = 0;
var timeout = null;
$('body').mousemove(function () {
last_seen = (new Date()).getTime();
window.clearTimeout(timeout);
timeout = window.setTimeout(clear_da_session, 10000);
});
Elements clearTimeoutand setTimeouttake care of something (ie, functions clear_da_session) that occurred after some time without running any of the following events.
However, I want to emphasize once again my comment from above: do not do this at home, children! Use everything that has your server language on board. This is much more reliable than trying to track something that might not be understood.
source
share