显示用户是否在线
check.ASP
<script language=javascript>
function Test()
{
var XMLhttp = new ActiveXObject("MSXML2.XMLHTTP");
XMLhttp.open("POST","online.ASP",false); // 向onceonline.asp发送更新请求
XMLhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
XMLhttp.send();
}
setInterval("Test();",10); // 10秒钟发送一次更新请求
</script>
online.ASP
<!--#include file="conn.ASP"-->
<%
conn.Execute "update hand_us set i='"&ii&"' where h=true and a='"&request.cookies("login_hand")&"'" '更新最后在线时间
conn.Execute "update hand_us set h=false where datediff('s',i,now())>1" '删除不在线的用户
enddata()
%>
本文介绍了一个使用ASP和JavaScript实现的简单在线状态检查机制。通过客户端定时向服务器发送请求来更新用户的在线状态,并定期清理离线用户。该方案适用于需要实时监控用户在线状态的应用场景。
2604

被折叠的 条评论
为什么被折叠?



