asp.net 如何对Session实现倒计时?

来源:百度知道 编辑:UC知道 时间:2024/05/15 20:11:32
想在站点会员登录后对其session进行倒计时,并在页面时实时显示,如"您的用户登陆信息有效时间还有:0时20分00秒之类的.如果用户进行了操作则不倒计时,当用户停止动作时就开始倒计时,时间到时session自动失效并弹窗提示或退出.请高手帮忙解答.先谢了.
希望用C#作下演示啊^_^,分不够可以再加.....

你直接复制就可以了
HTML部分:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function sessionTimeout()
{
var label=document.getElementById("lblTime");
var seconds=parseInt(label.value);
seconds=seconds-1;
label.value=seconds.toString();
if(seconds==0)
{
alert("您已超时");
window.location.href="login.aspx";//转到登陆页
clearInterval(sessionTimeout);
}
}
window.setInterval(sessionTimeout,1000);
</script>
</head>
<body>
<form id="form1" runat="server">
<div>剩余秒数: