用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧Delphi

不用Global.asa也可以实现在线人数统计

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 20:15:45
不使用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

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


'' 保持 SESSIONID
sql0 = "select sess from count where sess=''" & 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

''计算 sessionID
sql2 = "select count(sess) from count"
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%> Active users


Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:12,171.88000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号