Advanced Users Online
Many people have tutorials out there that allow you to count the number of active users online with the use of the global ASA file; however, they do not show you the user's location and "what they are doing".
i.e, going to your users_online.asp page may show the following:
- user J.Buttafucco is viewing the guestbook (/dev/guestbook.asp)
- user A.Fischer is deleting a guestbook entry (/dev/guestbook_delete.asp)
- user T.Harding is beating people up (/dev/beat_peeps_up.asp)
The Database
The first thing we need to do is to create a database in SQL 7. We'll call
this database TEST. Inside it, create a table called tblActiveUsers
(which will be dbo.tblActiveUsers)
Code in Global.asa
Now we need to create the
GLOBAL.ASA file (NOTE! You need to have an application setup in the IIS ISM.
If you don't have one set, create one for the website's root directory and then
just create the following global.asa and stick it in your root.)
<script language="vbscript" runat="server">
Sub Application_OnStart
Application.Lock
Application("usersOnline") = 0
Application("visits") = 0
Application.UnLock
End Sub
Sub Session_OnStart
Application.Lock
Application("usersOnline") = Application("usersOnline") + 1
Application("visits") = Application("visits") + 1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("usersOnline") = Application("usersOnline") - 1
Application.UnLock
End Sub
</script>
Ok, here's the deal though. You're not really counting active users. You're
counting active SESSIONS. The default time an IIS server will expire a session
is 20 minutes. So if 10 people are on your website and 1 leaves (dangit! use
my logout feature schmuck!) then this system will report 10 USERS ONLINE until
his session expires in 20 minutes (at which time a refresh will show 9 USERS
ONLINE) Speaking of which, my system will account for 1 USER ONLINE or 5 USERS
ONLINE (note the plural of USER)
Comments
Great
Great tutorial. Just one thing would have make things lot easier for the newbies. I can imagine that volks will have some problems in implementing the script so why not provide them the files and the database. Then things will be lot more easier to understand.
Anyways thanxalot finally i got it workin, was lookin for this for a long time.
RE: Great
Great??
I don't even know why its rated 4.7?? It doesnot work. There are many errors. I am working on it if somebody sorted out then please let me know.
You must me logged in to write a comment.