www.webdeveloper.com
Results 1 to 6 of 6

Thread: Global.asa problem

  1. #1
    Join Date
    Dec 2002
    Posts
    16

    Global.asa problem

    Hi,

    My code:

    Code:
    <script language="vbscript" runat="server">
    Sub Session_OnStart
    	Session("QID") = ""
    End Sub
    
    Sub Session_OnEnd
    	Dim con
    	Set con = Server.CreateObject("ADODB.Connection")
    	con.open "DRIVER={SQL Server};SERVER=SIT;UID=sa;PWD=;DATABASE=counseling"
    	
    	sql = "UPDATE Question SET Answered = 'F', Picked = 'F' WHERE ID = "&Session("QID")
    	
    	on error resume next
    	con.execute(sql)
    		
    	IF err.number = 0 THEN
    		Session("id") = ""
    		Session("user") = ""
    		Session("role") = ""
    		Session("school") = ""
    		Session("origin") = ""
    		'logout = "/fypj/logout.asp"
    		'current = Request.ServerVariables("SCRIPT_NAME")
    		'IF strcmp(current, logout, 1) THEN
    		'	response.redirect ("login.html")			
    		'END IF
    	END IF
    		
    	con.Close
    	Set con = Nothing
    End Sub
    </script>
    Problem lies when I actually close the browser, the Session_OnEnd event is not triggered

    Any idea why?

  2. #2
    Join Date
    Dec 2002
    Posts
    54

    Post

    HI,
    Session_OnEnd script gets a call whenever there is a session timeout or session end. When you close the browser (Before there is a session time out) then server ( which hosts the ASP scripts) does not get any indication that user has closed the browser. Server still waits for the inputs of user, and that is not a session end case for the server.
    --
    Vishal

  3. #3
    Join Date
    Dec 2002
    Posts
    16

    Unhappy

    Is there a way I can indicate the server that the user has closed the browser?

  4. #4
    Join Date
    Dec 2002
    Posts
    54
    Originally posted by jux82
    Is there a way I can indicate the server that the user has closed the browser?
    Writing code in Session_OnEnd is not a very reliable solution. Please let me know the requirement, mau be i will suggest a better work around. A perfect solution.

    Vishal

  5. #5
    Join Date
    Dec 2002
    Posts
    16
    Since u asked for it, I will let u know

    I am doing a counseling application.
    Public can send message through their phone (SMS) to our server to ask question.
    An asp page, which the counselor uses to answer the question, will retrieve this question from Inqueue database.
    When a question is retrieved, it is considered locked by this particular counselor.
    Other counselor will never answer the same question.
    Then here lies the problem.
    What if the counselor accidentally closes the browser?
    What if the counselor leaves the question unanswered?
    What if he presses log out button?
    What if the client machine crash?

    Those are things I have got to take care of.

    For now, I managed to solve the 2nd and 3rd problem listed using Session_OnEnd event.
    And the 1st and 4th listed are the ones that I need to solve now.

    Hope that clears what my requirements are.

  6. #6
    Join Date
    Dec 2002
    Posts
    54
    HI,
    Sorry for the delay of this post. Hope your problem has been solved now. If it is still open then I will like to suggest you one work around for this. This solution doesn't have to deal with Session_onEnd event or something like that. Its straight forward.
    What you want is.. If a counselor opens a question, you want to lock that question against that counselor only so that no one else can open that. Now if counselor closes the window or doesn't answer that time then also you want to lock that question against him.
    So what you should do?
    When ever counselor opens a question to ans, On the same asp page, first of all you set the database field value as locked against that counselor. NOw if he gives the answer then you can override the status otherwise in all other cases, your question will be locked against the counselor. So by this way there will not be any need for Session_OnEnd Event.

    Inform me, if it makes any sense to you.
    Vishal Gupta

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles