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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Classic Logout Issue

Status
Not open for further replies.

rhnewfie

Programmer
Jun 14, 2001
267
CA
Alright, I know that everyone here has probably wrestled with this at somepoint --> Ensuring Logout on Actual logout, session expiry, and browser close.

I have a site that will only allow 1 person to log in with a given username at one time. When someone logs in I change a field in the DB to hold the fact that they are logged in. If they actually log out then I am fine, the DB gets updated. However, the problem lies in if they timeout or close the browser.

I know that the session information is gone before we hit the Session_OnEnd event, which supposedly fires on browser close and session timeout so I can't use that information to ensure that I update my table appropriately.

Has anyone else had to handle this? What can I do on session timeout or browser close to update my DB? I would need to have the users id of course.

I have thought about a Body onUnload event but this does not seem to fire on browser close.

Any ideas would be great!
 
Maybe you could update your "person logged in" table every time a logged in user requests a page instead of only when they first logged in... you would update a field for "last page request time" or somesuch...

Then run a little scheduled job every 12 hours that looks for logged in users that have not made a request in a long while.

This will also help protect you against those times when the power goes out but the UPS failed... or the CPU in the server released its magic smoke... or some other tragic hardware failure.
 
I guess something like that could work. I could check to see if someone tries to log in with a logged in username and if the last page request was greater then the 20 minute timeout limit then log them in etc... SOmething cleaner would be nice. Still working on it though.

Something so basic should not be so hard...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top