Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy What's wrong with my Global.asa file?

    Hi all,
    I am trying to track all my members of my website.

    I have a global.asa file:

    Code:
    <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..,


  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    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.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks . Seems I have to try different way....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •