标题:请问一个ASP问题.
只看楼主
fkewxai
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2004-10-10
 问题点数:0 回复次数:6 
请问一个ASP问题.
请问:在ASP中怎样统计在线用户并显示出来???
搜索更多相关主题的帖子: ASP 
2004-10-10 19:30
hlc9279
Rank: 1
等 级:新手上路
帖 子:39
专家分:0
注 册:2004-9-21
得分:0 

这个问题很多方法~我最欣赏这样写,因为不用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%>人在我这里流连忘返!

2004-10-10 21:14
刹那
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2004-10-11
得分:0 
恩   不错   顶

当爱已成往事....
2004-10-11 21:57
好学
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
帖 子:622
专家分:318
注 册:2004-5-4
得分:0 
好办法,2楼的有好作品吗?展示看看
2004-10-12 06:11
regedit
Rank: 5Rank: 5
等 级:贵宾
威 望:19
帖 子:950
专家分:0
注 册:2004-6-8
得分:0 
以下是引用hlc9279在2004-10-10 21:14:32的发言:

这个问题很多方法~我最欣赏这样写,因为不用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%>人在我这里流连忘返!

好,我刚刚好正在想一个不用Global.asa来实现的在线人数统计!!3939


最新作品:百货品牌商品资讯第一门户([url]http://www./[/url]),欢迎交流
2004-10-12 09:39
fkewxai
Rank: 1
等 级:新手上路
帖 子:23
专家分:0
注 册:2004-10-10
得分:0 

如果不用数据库,而用数组又应该怎样实现在线人数统计、并显示在线用户? 请各位高手指点迷津!!!!

2004-10-12 22:31
weinqiang
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2004-10-17
得分:0 

不错啦

2004-10-31 00:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-6305-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.222938 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved