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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-17 我要评论
想了解不用Global.asa也能实现统计在线人数吗?的相关内容吗,在本文为您仔细讲解的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:不用用GGlloobbaallaassaa也也能能实实现现统统计计在在线线人人数数吗吗??,下面大家一起来学习吧。

不用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]

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们