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

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了不用Global.asa也能实现统计在线人数吗?脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

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

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

Conn_String = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" &amp; 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%>人在随风起舞流连忘返!

 

[1]@H_435_126@

脚本宝典总结

以上是脚本宝典为你收集整理的不用Global.asa也能实现统计在线人数吗?全部内容,希望文章能够帮你解决不用Global.asa也能实现统计在线人数吗?所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: