不用Global.asa也能实现统计在线人数吗?
不用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]
您可能感兴趣的文章
- 01-11网上考试设计思路是怎样的?
- 01-11如何实时获知多少人在线?
- 01-11统计在线人数是实时的吗?
- 01-11如何让用户也能修改密码?
阅读排行
本栏相关
- 01-11如何实现点击数的计算?
- 01-11如何做一个文本搜索?
- 01-11如何判断电子邮件的地址格式是否正
- 01-11如何实现全文检索?
- 01-11如何实现网上考试?
- 01-11如何使用表单发送电子邮件?
- 01-11如何用POP3接收电子邮件?
- 01-11如何取回已忘记的密码?
- 01-11如何在线更改密码?
- 01-11如何做一个随机密码产生器?
随机阅读
- 08-05DEDE织梦data目录下的sessions文件夹有什
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 01-11ajax实现页面的局部加载
- 01-10C#中split用法实例总结
- 01-10delphi制作wav文件的方法
- 04-02jquery与jsp,用jquery
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-10SublimeText编译C开发环境设置