Click to See Complete Forum and Search --> : Global.asa / Session_OnEnd


nike
10-10-2006, 09:21 AM
I am tracking all activity on one of my sites, but if the user does not hit the LOGOUT button, I don't get a Logged out entry. I would like to stick it into the global.asa file so that it will do it when their session ends no matter how they exit.

This code below is what I have in my asa file now, but does not seem to be working.

Sub Session_OnEnd
IF Session("USER_ID") <> 0 THEN
oDb = Server.CreateObject("adodb.connection")
ConnStr = "SQL CONNECTION STRING"
oDb.Open(ConnStr)
oDb.Execute("INSERT INTO Log (mLogin, IP, EventTime, EventDescr) VALUES("+Session("USER_ID")+", '"+Session("USER_IP")+"', GetDate(),'Log Out')")
END IF

End Sub

Any ideas?

jvanamali
10-10-2006, 01:48 PM
session end fires 20 mins (default) after closing the browser, not immediately. we had almost the same requirement and it worked for us.

first try to write some thing in the session end , that executes without the if statement, this way you whether the event is firing or not. if the event is firing then yu can go there.

you can also try connecting from another system and the not the system that you are running your code, i don't why but our code didnot work properly when we closed the browser on the server (where is code was running) but it worked fine if we opened and closed from other systems.