欢迎来到入门教程网!

编程问答

当前位置:主页 > 网络编程 > 编程问答 >

不用Global.asa也能实现统计在线人数吗?

来源:本站原创|时间:2020-01-11|栏目:编程问答|点击:

不用Global.asa也能实现统计在线人数吗?

<%
sessionID = session.SessionID
timeout = 5
'
设置session保持的时间.

Conn_String = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("count.mdb")
'Conn_String = "activeUser"
'
最好设置DSN = "activeuser",因为我们需要在所有的ASP脚本中包含这个文件.

Set ConnCount =Server.CreateObject("ADODB.Connection")
ConnCount.Open Conn_String

aaa = dateadd("n", -timeout, now())
connCount.Execute ("delete * from count where postdate < #" & aaa & "#")
'
在超时后删除session.

sql0 = "select sess from count where sess='" & sessionID & "'"

' 保持sessionID.
set rscheck = connCount.Execute (sql0)
if rscheck.eof then
sql = "insert into count (sess,postdate) values('" & sessionID & "', '" & now() & "')"
connCount.Execute (sql)
end if
rscheck.close
set rscheck = nothing

sql2 = "select count(sess) from count"

' 计算sessionID.
set rs = connCount.Execute (sql2)
count = rs(0)

rs.close
set rs = nothing

sql3 = "select * from count"
set rspredel = connCount.Execute (sql3)
do until rspredel.eof
xxx=DateDiff("n", rspredel("postdate"), Now())
if xxx > timeout then
count = count-1
end if
rspredel.movenext
loop
rspredel.close
set rspredel = nothing

connCount.Close
set connCount = nothing

if count = 0 then
count = 1
end if
%>

当前正有<%=count%>人在随风起舞流连忘返!

 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

[1]

上一篇:如何用ASP发送html格式的邮件?

栏    目:编程问答

下一篇:如何用ASP发送带附件的邮件?

本文标题:不用Global.asa也能实现统计在线人数吗?

本文地址:https://www.xiuzhanwang.com/a1/bianchengwenda/12088.html

网页制作CMS教程网络编程软件编程脚本语言数据库服务器

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:835971066 | 邮箱:835971066#qq.com(#换成@)

Copyright © 2002-2020 脚本教程网 版权所有