Click to See Complete Forum and Search --> : Global.asa problem
jux82
12-26-2002, 01:05 AM
Hi,
My 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?
vishu_gupt
12-26-2002, 07:55 AM
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
jux82
12-26-2002, 08:36 PM
Is there a way I can indicate the server that the user has closed the browser? :(
vishu_gupt
12-27-2002, 12:19 AM
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
jux82
12-27-2002, 02:58 AM
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.
vishu_gupt
01-08-2003, 02:57 AM
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.