Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session management help

Status
Not open for further replies.

hopper

Programmer
Dec 5, 2000
27
0
0
US
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.

Any help would be greatly appreciated.

Thanks,
Hopper
 
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??

Simon
 
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

Session.Abandon
Response.Redirect "index.html"

Is there anything I am forgetting? Does it have anything to do with the ldb file?
 
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:

Session.Abandon
Response.Redirect "index.html"

Is there anything I am missing? Is there anything with the ldb file?

 
You could try issuing a lower
Code:
Session.Timeout
value, and/or issuing a
Code:
Session.Contents.RemoveAll
This might help, but I don't know. Could you be a bit more explicit in what is happening and what you want?

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
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?

Monte Kalisch
montek@montekcs.com
 
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?
 
hopper,

> Is that correct?

Yes it is correct. There is no mechanism to know when a user leaves you site other than a timeout.

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top