Home Page

Live Real Time User Monitoring in ASP and SQL!

This is great way to monitor user and bot activity in real time... I have tried many different methods and this is hands down the best way to go... my coding isn't always the cleanest but it works... you could actually move the connstring to one include but for example purposes I'm showing the connection string in all places its need.

Create the The Databases.

Call this one "sessions"

Use the following to build the table automatically (copy and paste in Query Analyzer):

Table will be like this:

Column Name Data Type Length Allow Nulls
SessionID ***  make this the active key as well varchar 24 no
LastActivity **** default vale = getdate() smalldatetime 4 no
Active **** default value = 1 bit 1 no
PATH_INFO varchar 500 yes
REMOTE_ADDR varchar 20 yes
HTTP_USER_AGENT varchar 500 yes
HTTP_REFERER varchar 999 yes
URL varchar 999 yes
QUERY_STRING varchar 999 yes

You will have to manually edit the table to add the default values ******

Call this one "properties"

Use the following to build the table automatically (copy and paste in Query Analyzer):

Table will be like this:

Column Name Data Type Length Allow Nulls
PName varchar 32 no
IntP int 4 yes
DateTimeP datetime 8 yes
VarcharP varchar 255 yes

Edit this table now... the only required is the first value for timeout period... I used 5

 

Stored Procedures needed (copy and paste into Query analyzer to quickly build these).

The Global.asa settings:

Include on every page (session.asp):

<!-- #include virtual="/include/session.asp"-->
--or --
<!-- #include file="session.asp"-->

The monitering page: