<SCRIPT LANGUAGE=VBScript RUNAT=Server> Sub Application_onStart '初始值为0 Application("OnLine") = 0 End Sub
Sub Session_onStart '一个用户访问进行记数加1 Application.Lock Application("OnLine") = Application("OnLine") + 1 Application.Unlock End Sub
Sub Session_OnEnd '一个用户进程的结束,记数减1 (P.S.如果没有该事件程序,则执行的就是页面访问程序了。) Application.Lock Application("OnLine") = Application("OnLine") - 1 Application.Unlock End Sub </SCRIPT>
3,online.asp
<% if request.querystring("logout")="true" then session.Abandon() response.end end if %> 当前共有<%=Application("OnLine")%>在线 <a href="online.asp?logout=true">退出</a>
<% if request.querystring("logout")="true" then session.Abandon() response.end end if %> <body onunload=javascript:window.open("exit.asp")> 当前共有<%=Application("OnLine")%>在线 <a href="online.asp?logout=true">退出</a>
<SCRIPT LANGUAGE="VBScript" RUNAT="Server"> Sub Application_OnStart application("online")=0 End Sub
Sub Session_OnStart End Sub
Sub Session_OnEnd if session.contents("pass") then '判断是否为登录用户的Session_OnEnd application.lock application("online")=application("online")-1 application.unlock end if End Sub
<% if request.querystring("logout")="true" then session.Abandon() end if submitname=request.form("submit") if submitname="submit" then name=request.form("name") pwd=request.form("pwd") if name="cnbruce" and pwd="cnrose" then session("name")=name session("pass")=true else response.write "Error Name Or Pwd.<a href='login.asp'>Back</a>" response.end end if application.lock application("online")=application("online")+1 application.unlock %> 当前注册会员<%=application("online")%>人。 <a href="login.asp?logout=true">退出</a> <%else%> <form action="login.asp" method="post"> <input type="text" name="name"><br> <input type="password" name="pwd"><br> <input type="submit" name="submit" value="submit"> <%end if%>