关于在线显示的问题????????着急着急着急着急着急

上官云峰 2004-11-22 04:44:39
我要做一个页面,在多个用户访问的时候能够得出:
1)全部在线用户名
2)当前在线人数
...全文
97 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
newskyline 2004-11-22
  • 打赏
  • 举报
回复
Global.asa里可以这样写:
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_onStart '初始值为0
Application("OnLine") = 0
End Sub

Sub Session_onStart '一个用户访问进行记数加1
Application.Lock
Application("OnLine") = Application("OnLine") + 1
Application.Unlock
End Sub

Sub Session_OnEnd '一个用户进程的结束,记数减1 (P.S.如果没有该事件程序,则执行的就是页面访问程序了。)
Application.Lock
Application("OnLine") = Application("OnLine") - 1
Application.Unlock
End Sub
</SCRIPT>

以上是统计总在线人数的。
在线会员的显示则最好结合数据库了,在tUser表中添加一个IsOnline(Bool)字段来记录用户是否在线,用SQL语句COUNT一下就可以了。
huangjinyin 2004-11-22
  • 打赏
  • 举报
回复
你也可以建一张在线用户表,这样很容易实现的
jixinming 2004-11-22
  • 打赏
  • 举报
回复
可以在Global.asa文件中定义一些session和Application,具体你看一下关于Global.asa文件的介绍就行,一般都会有这个问题的。
liuyangxuan 2004-11-22
  • 打赏
  • 举报
回复
Use Application For Global.asa In Folder!
net_boy 2004-11-22
  • 打赏
  • 举报
回复
你可以在session_onstart 里 加代码 当用户登陆时 把他放在数据库中(在线用户表),
当他离线时 在session_onend 里 加代码 删出这个用户
那么你做的这个在线显示的文件 任务就是从数据库中读值 给你个思路了
你试试看 对不对
baikaishui_0825 2004-11-22
  • 打赏
  • 举报
回复
顶啊!~~
iuhxq 2004-11-22
  • 打赏
  • 举报
回复
<!--#include file="chksql.asp" -->
<%
ip=request.servervariables("http_x_forwarded_for")
if ip="" then
ip=request.servervariables("remote_addr")
end if
set rs=server.CreateObject("adodb.recordset")
ss=chksql(session.SessionID)
uname=chksql(request.Cookies("username"))
ere=chksql(request.Cookies("eremite"))
sql="select * from online where ip='"&ip&"'and (sessionid="&ss&" or username='"&uname&"')"
rs.open sql,conn,3,3
if rs.eof and rs.bof then
rs.addnew
rs("sessionid")=ss
rs("username")=uname
rs("eremite")=ere
rs("ip")=ip
rs("acturl")=cstr(Request.ServerVariables("script_name"))
rs("lasttime")=now
else
rs("acturl")=cstr(Request.ServerVariables("script_name"))
rs("lasttime")=now
end if
rs.update
rs.close
conn.execute("delete from online where datediff('s', lasttime, now())>7200")
%>
手机APP开发 2004-11-22
  • 打赏
  • 举报
回复
up

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧