No Global.asa to achieve online headcount statistics

Source: Internet
Author: User
Statistics | online | online number <%
' Count online user without using Global.asa
' Script by Narong Khotarasakit
' Webmaster of ezebox.com
' Bug:info@ezebox.com


SessionID = Session. SessionID
Timeout = 5
' Set how long to keep this session in minute can increase this number

conn_string = "Driver={microsoft Access DRIVER (*.mdb)};D bq=" & Server.MapPath ("Count.mdb")
' conn_string = ' activeuser '
' Set your DSN = ' activeuser ' is a better way because and need include this file to all your ASP scripts.


Set conncount =server.createobject ("ADODB.") Connection ")
Conncount.open conn_string

' Delete session after timeout
AAA = DATEADD ("n",-timeout, Now ())
Conncount.execute ("Delete * from Count where Postdate < #" & AAA & "#")


' Keep SessionID
sql0 = "Select Sess from Count where sess= '" & SessionID & "" "
Set Rscheck = Conncount.execute (sql0)
If Rscheck.eof Then
sql = "INSERT into count (sess,postdate) VALUES (' & SessionID & ', '" & Now () & "")
Conncount.execute (SQL)
End If
Rscheck.close
Set Rscheck = Nothing

' Count SessionID
SQL2 = "SELECT count (sess) from Count"
Set rs = Conncount.execute (SQL2)
Count = RS (0)
Rs.close
Set rs = Nothing


SQL3 = "SELECT * from Count"
Set Rspredel = Conncount.execute (SQL3)
Do Until rspredel.eof
Xxx=datediff ("n", Rspredel ("Postdate"), Now ())
If xxx > timeout then
Count = count-1
End If
Rspredel.movenext
Loop
Rspredel.close
Set Rspredel = Nothing

Conncount.close
Set conncount = Nothing

If Count = 0 Then
Count = 1
End If
%>

<%=count%> Active Users



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.