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

来源:asp之家 时间:2009-10-29 12:28:00 

可以的,看看下面的代码和说明:

<%
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%>人在asp之家流连忘返!


 

标签:Global.asa,统计,在线人数,asp
0
投稿

猜你喜欢

  • 利用Python开发实现简单的记事本

    2023-07-02 13:27:27
  • C#实现的ACCESS数据库操作类完整实例

    2024-01-20 02:57:36
  • Pandas使用Merge与Join和Concat分别进行合并数据效率对比分析

    2023-03-13 12:14:01
  • linux环境下的python安装过程图解(含setuptools)

    2021-03-31 13:03:56
  • 在sqlserver中如何使用CTE解决复杂查询问题

    2024-01-24 13:31:34
  • MySQL无法存储emoji表情解决方案分析

    2024-01-14 18:57:00
  • SQL语句实现查询当前数据库IO等待状况

    2024-01-17 02:04:32
  • python好玩的项目—色情图片识别代码分享

    2022-01-26 03:19:19
  • 10分钟教你用Python实现微信自动回复功能

    2021-03-14 04:04:47
  • 通过实例了解Render Props回调地狱解决方案

    2024-04-22 13:04:36
  • Python语言实现将图片转化为html页面

    2023-09-24 01:21:02
  • Python堆排序原理与实现方法详解

    2021-02-22 15:07:31
  • python生成九宫格图片

    2022-09-09 04:46:34
  • 使用Go实现优雅重启服务功能

    2024-04-25 15:06:06
  • go slice 数组和切片使用区别示例解析

    2023-06-22 04:07:16
  • Python3.6笔记之将程序运行结果输出到文件的方法

    2023-08-02 08:27:44
  • VC基于ADO技术访问数据库的方法

    2024-01-28 22:25:08
  • python实现将range()函数生成的数字存储在一个列表中

    2021-12-19 08:01:51
  • python+numpy+matplotalib实现梯度下降法

    2023-07-26 04:07:35
  • 用Python登录好友QQ空间点赞的示例代码

    2023-08-08 09:29:40
  • asp之家 网络编程 m.aspxhome.com