...

View Full Version : What's wrong with my Global.asa file?



jerriey
01-18-2005, 04:34 AM
Hi all,
I am trying to track all my members of my website.

I have a global.asa file:




<script language="vbscript" runat="server">


Sub Application_OnStart

Application("Conn") = "connection string"
Application("Now") = Date() & " " & Time()

End Sub

Sub Session_OnStart

Session.Timeout = 20

if session("ManagerName")<>"" then


SQL = "Insert Into tbl_ManagerTracker (col_timeStart) Values('col_timeStart')"

Set MM_insert = Server.CreateObject("ADODB.Command")
MM_insert.ActiveConnection = Application("Conn")
MM_insert.CommandText = SQL
MM_insert.Execute
MM_insert.ActiveConnection.Close

Set MM_insert = Nothing

end if

End Sub

Sub Session_OnEnd


Set ManagerEnd = Server.CreateObject("ADODB.Recordset")
ManagerEnd.ActiveConnection = Application("Conn")
ManagerEnd.Source = "SELECT col_timeEnd FROM tbl_Tracker where col_timeStart ="&col_timeStart&" "

ManagerEnd.Locktype = 3
ManagerEnd.Open()

ManagerEnd.fields("col_timeEnd")= Application("Now")

ManagerEnd.update()
ManagerEnd.close()
End Sub

</script>


First of all, my session("ManagerName") been set up by user login, but it's value getting null while the global.asa running.

Then, Sub Session_OnEnd command seems not to be working at all...

I know it is a quite old topic, but please please help!!! Thanks..,

:confused: :confused: :confused: :confused: :confused: :confused:

glenngv
01-18-2005, 06:57 AM
Session_OnStart is invoked when a user access the very first asp page in the site. Say User A goes to the home page which is an ASP page, before this ASP page is executed, Session_OnStart is executed first. Succeeding access to other asp pages will not invoke that handler until the session times out or abandoned. Therefore in the Session_OnStart handler, you don't need this condition:

if session("ManagerName")<>"" then

But if you only want to track if the user is a manager, then you have to do that after the successful login, not in global.asa.

Session_OnEnd is invoked after the session times out for a user or the session is abandoned (log out). If the user did not log out properly and just closes the browser window, Session_OnEnd is not invoked, only after the session times out for that user. So if the timeout is 20 minutes, the handler will be executed after that time when the user closes the browser.

jerriey
01-19-2005, 01:34 AM
thanks . Seems I have to try different way....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum