开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院ASP技术打印相关 → 用asp显示当前在线用户信息,不是简单只显示人数那种![1]
用asp显示当前在线用户信息,不是简单只显示人数那种![1]
日期:2000年9月4日 作者: 人气:     [ ]
东子 于 00-9-3 上午 02:35:55 发表在:ASP地带

global.asa 放在你的根目录
<object runat="Server" scope="Application"
id="rstActiveUsers" progid="ADODB.Recordset">
</object>

<script language="VBScript" runat="Server">
' The first thing you should notice is the top line.
' It creates an application scoped recordset object
' named rstActiveUsers that I'll use to store all
' our user information.
'
' Note: I've wrapped it for readability

Sub Application_OnStart()
    ' Selected constants from adovbs.inc
    Const adInteger = 3
    Const adVarChar = 200
    Const adDate = 7
    
    ' Here I set up in memory active user recordset
    ' by adding the fields I want to it and defining
    ' their data types.
    rstActiveUsers.Fields.Append "id", adInteger
    rstActiveUsers.Fields.Append "ip", adVarChar, 15
    rstActiveUsers.Fields.Append "browser", adVarChar, 255
    rstActiveUsers.Fields.Append "started", adDate

    ' Next I open our recordset so that we can use it.
    ' That basically gets everything ready for our
    ' first user.
    rstActiveUsers.Open
End Sub

Sub Session_OnStart()
    ' Set session timeout to 20 minutes
    Session.Timeout = 20

    ' Set a session start time.  This is pretty pointless,
    ' but it does ensure that we start a session and
    ' assign the user a session id and it can help
    ' troubleshooting if we ever need it.
    Session("Start") = Now()
    
    ' Move to the end so records are added in order.
    ' Again not of any real importance, but it keeps our
    ' user table nice and orderly.
    If Not rstActiveUsers.EOF Then rstActiveUsers.MoveLast

    ' Add a record and insert users data.  I'm just
    ' storing some basic info, but naturally you're free
    ' to store whatever you want.
    rstActiveUsers.AddNew
    
    rstActiveUsers.Fields("id").Value = _
        Session.SessionID
    
    rstActiveUsers.Fields("ip").Value = _
        Request.ServerVariables("REMOTE_HOST")
    
    rstActiveUsers.Fields("browser").Value = _
        Request.ServerVariables("HTTP_USER_AGENT")
    
    rstActiveUsers.Fields("started").Value = _
        Now()
    
    rstActiveUsers.Update
    
    ' Now that we've got the information, all that's
    ' left is to display it.  See test_page.asp for a
    ' demo.  It includes the pages show_count.asp and
    ' show_users.asp which can also be used
    ' individually if desired.
End Sub

Sub Session_OnEnd()
    ' Selected constants from adovbs.inc
    Const adSearchForward = 1
    Const adBookmarkFirst = 1
    Const adAffectCurrent = 1

    ' Find the appropriate record.  Using session id is the
    ' easiest way since I use this as the primary key.
    ' This line positions us on the appropriate record.
    rstActiveUsers.Find "id = " & Session.SessionID, _
        0, adSearchForward, adBookmarkFirst
    
    ' Now that we're on the record, delete it.
    ' I use the EOF to make sure we've got one.
    If Not rstActiveUsers.EOF Then
        rstActiveUsers.Delete adAffectCurrent
    End If
End Sub

(出处:)

相关文章:
 
·SQL Server 2000 SP4发布
·Sql Server 2005最新CTP简介及截图
·微软发布数据库新测试版 最终版明夏登场
·网络社区论坛即将成为互联网下一热点
·SET NOCOUNT的用法和注意事项
·全正则的检测IP是否合法的函数
·判断一个access数据库中某个表是否存在的方法
·用Asp生成条形码
·数字小写到英文大写的转换
·在不支持FSO的服务器上使用XMLDOM创建HTML文件
相关软件:
 
·拓域会员核心系统 v1.02
·深博贴吧(仿百度)双数据库版 v1.5
·通用草稿自动保存系统SipoAutoSaver v2.0
·BJXSHOP网上开店专家 v6.0 SP1 Build 20060118
·企业网站智能管理系统(TZIMS) v1.5
·bzmtv v1.0 正式版
·宜兴二级域名申请系统SQL版
·Mslove交友系统 v3.0
·亿人通讯录 v3.0
·深博贴吧(仿百度)双数据库版 v1.0
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077