不用Global.asa实现在线人数统计

 1   
 2'count online user without using Global.asa   
 3'script by Narong Khotarasakit   
 4'webmaster of ezebox.com   
 5'report bug : [email protected]   
 6  
 7  
 8sessionID = session.SessionID   
 9timeout = 5   
10' set how long to keep this session in minute you can increase this number   
11  
12Conn_String = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("count.mdb")   
13'Conn_String = "activeUser"   
14'set your DSN = "activeuser" is a better way because you need include this file to all your asp scripts.   
15  
16  
17Set ConnCount =Server.CreateObject("ADODB.Connection")   
18ConnCount.Open Conn_String   
19  
20' delete session after timeout   
21aaa = dateadd("n", -timeout, now())   
22connCount.Execute ("delete * from count where postdate < #" & aaa & "#")   
23  
24  
25' keep sessionID   
26sql0 = "select sess from count where sess='" & sessionID & "'"   
27set rscheck = connCount.Execute (sql0)   
28if rscheck.eof then   
29sql = "insert into count (sess,postdate) values('" & sessionID & "', '" & now() & "')"   
30connCount.Execute (sql)   
31end if   
32rscheck.close   
33set rscheck = nothing   
34  
35'count sessionID   
36sql2 = "select count(sess) from count"   
37set rs = connCount.Execute (sql2)   
38count = rs(0)   
39rs.close   
40set rs = nothing   
41  
42  
43sql3 = "select * from count"   
44set rspredel = connCount.Execute (sql3)   
45do until rspredel.eof   
46xxx=DateDiff("n", rspredel("postdate"), Now())   
47if xxx > timeout then   
48count = count-1   
49end if   
50rspredel.movenext   
51loop   
52rspredel.close   
53set rspredel = nothing   
54  
55connCount.Close   
56set connCount = nothing   
57  
58if count = 0 then   
59count = 1   
60end if   
1=count
2``` Active users
Published At
Categories with Web编程
Tagged with
comments powered by Disqus