How can I detect when a user closes an asp page so I can call abandon() to kill their session?
I've tried to use the global.asa file but I can't seem to get that to work. Probably using it wrong.
If you want to call Session.Abandon, then you must have a button (or something else) that signifies the user is "logging out". The problem you will have with this is that the user may just close the browser, so not clicking on the "Log Out" button. I don't know precisely how the global.asa file handles this but there should be a Session event that you can code so this will call Session.Abandon. How have you tried to implement this??
I am having a similar problem. I can log in and then log out and then log in fine with a user, but when I log in and perform actions(ie.Update Customer Profile) and then log out and then log in again with that same user it will not log me in. My code behind my log out button is
I am having a similar problem. I am able to login, logout and then log back in with the same customer. But when I log in, perform some actions (ie Update Customer Profile) and then log out, then log back in with the same customer it will not let me login. My logout code is listed below:
Unless you've changed the timeout in IIS or within your ASP pages, the default will be 20 minutes. So after 20 minutes of a user not contacting the server again, their ASP session will be removed. Of course, you can *force* the disconnect by calling Session.Abandon (via a logout button or something) just like RChan suggested.
Session.Abandon or the Session timing out will both call the Session_OnEnd() routine in the global.asa, if present.
RChen: What is your login code? What do you mean it will not let you login again?
I do have the Log Out button which does call the Session.Abandon, but I was trying to find a way to close the session if the user closes the browser, or leaves the site without using the log out button. I've read about using the onunload function in javascript to call another window with the session.abandon in it but my understanding is that if the user accesses a different page the onunload will fire and kill the session. Is that correct?
I also have set the timeout in IIS to 5 minutes. Do I still need to implement the On_SessionEnd in the global.asa to Session.Abandon or will the timeout kill the session properly?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.