优秀的软件开发团队:深圳升蓝软件 数据库开发 .Net技术  |  ASP技术 PHP技术 JSP技术 应用技术类     
热门推荐
升蓝OA办公自动化系统
基于.Net技术的网络
协同办公环境
 
ASP基础
数据库相关
安全加密
全文检索
ASP应用
打印相关
客户端相关
XML相关
系统相关
正则表达式
ASP技巧
组件开发
脚本编码
FSO专题
邮件相关
远程脚本
性能优化
 
相关链接
深圳升蓝软件:系统集成、办公自动化平台、电子商务、电子政务、Web数据库、企业网站、游戏、手机应用程序、CDMA软件、电子出版物等,为客户提供优秀的解决方案
 
升蓝(www.hi-blue.com)为企业管理、政府办公提供成熟的、易于实施的IT技术服务,我们的解决方案包括OA办公自动化系统CRM客户关系管理系统ERP企业生产管理和订单管理系统电子政务系统、知识管理系统、企业门户、商业智能、工程项目管理等等...
 
电子政务解决方案
塑料/橡胶管理系统
知识管理系统简介
多媒体光盘方案
ERP企业资源管理
订单计划管理系统
PM工程项目管理系统
会员管理系统
相关资料下载
OA办公自动化系统
CRM客户关系管理系统
在线试用版本说明
OA 系统的用户手册
 
 
 
 
升蓝开发团队 > 技术资料 > ASP技术 > 打印相关 : 用asp显示当前在线用户信息,不是简单只显示人数那种?/td>

用asp显示当前在线用户信息,不是简单只显示人数那种?/H1>
March 25,2004

东子 于 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
数据库开发 | .Net技术 | ASP技术 | PHP技术 | JSP技术 | 应用技术类 | 升蓝开发小组
Copyright ? 2001-2004 Shenzhen Hi-blue Software Team 升蓝开发小组 All rights reserved