|
主题: 请教ASP中的在线时间统计问题
|
 ???
职务:普通成员
等级:2
金币:10.0
发贴:644
|
#12003/9/22 15:39:18
用户管理,如何统计用户每次登录的在线时间,并纪录在库里? 不用说想法,只求核心代码 谢谢!
|
 janlay
职务:管理员
等级:7
金币:28.0
发贴:7244
|
#22003/9/22 16:09:27
首先,需要一张用户在线时间表,这个表至少要包含以下信息:
用户ID SessionID(用来标识此用户的信息) 登录时间 上次活动时间(也就是用户最近一次向服务器提交请求的时间) 退出时间(未退出时为Null值)
有可能还包含这些信息: 用户位置(他在干嘛呢?) 用户状态(是否隐身,是否被封,是否。。。) ……
收到用户请求后,检查该用户标识信息是否存在于表中,并且退出时间是否为空,如果是,就update,否则,insert. 说明一下,其实用户也可以作为鉴别信息的,但是有可能有不同的人使用相同的用户登录。如果加入另一个鉴别信息,就可以判断这种情况。
在检查之前,还要做一件事,就是检查会话过期(建议这个时间略大于session的timeout时间)的用户,将当前时间写入到退出时间中。这是一种非正常的退出(没有经过退出程序)。 正常的退出程序中,也要写入这个退出时间。
|
 ???
职务:普通成员
等级:2
金币:10.0
发贴:644
|
#32003/9/22 17:19:07
谢谢,不过我需要的是核心代码的写法
|
 janlay
职务:管理员
等级:7
金币:28.0
发贴:7244
|
#42003/9/22 17:59:04
引用: 不用说想法,只求核心代码
我刚好看反了  ASP是一种结构化和模块化都很弱的语言,代码之间相互关联太多了。脱离了必要的辅助代码,核心代码就没有存在的意义了。 宁愿要“鱼”而不要“渔”,为什么现在的人都这么急功近利呢
|
 ???
职务:普通成员
等级:2
金币:10.0
发贴:644
|
#52003/9/22 18:26:31
赫赫,你说得我都明白,原理我也明白,只是N年没有用了,忘了语法了!辅助代码我倒是没有什么问题。赫赫
|
 ???
职务:普通成员
等级:2
金币:10.0
发贴:644
|
#62003/9/23 9:05:47
轻轻UP一下
|
 风之翅
职务:普通成员
等级:2
金币:10.0
发贴:540
|
#72003/9/23 19:17:53
正好我也想加上这样的功能,我的想法是在register数据表里建login,logout,onlinetime字段,分别代表登入时间,退出时间,在线时间,其中在线时间=上次在线时间+最新在线时间,现在已经取得那前2个字段的值,关键是在线时间该怎么写 我想是onlinetime+DateDiff("m",[login],[logout]) 现在有几个问题: 1.onlinetime字段该取什么数据类型 2.DateDiff("m",[login],[logout])语句不对,提示出错
|