Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using "cookies" to maintain session in my asp.net application.

What I want is that when a user logs in to my website and remains idle for 10 minutes it should automatically log them out and redirect them to the login page.
Posted

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Show alert message when user idle for sometime on webiste</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js"></script>
<script type="text/javascript" src="jquery.idle-timer.js"></script>
<script type="text/javascript">

$(function() {
var timeout = 5000;
$(document).bind("idle.idleTimer", function() {
$("#status").html("User is idle :(").css("backgroundColor", "silver");
alert("user idle for more than "+ (timeout/1000)+" secs")
});
$(document).bind("active.idleTimer", function() {
$("#status").html("User is active :D").css("backgroundColor", "yellow");
});
$.idleTimer(timeout);
});

</script>
</head>
<body>
<form runat="server" id="form1">
<h1>YOUR PAGE;/h1><h3>Showing User Active & Idle Status based on Time</h3>
<div id="status" style="padding: 5px;">&nbsp;</div>
</form>
</body>
</html>



You can download and add some jquery file which is mentioned....
 
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