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!

browser closing 2

Status
Not open for further replies.

wekoweko

Programmer
Feb 1, 2004
18
0
0
PH
hi there, wanted to ask if there is any method existent in html that would automatically detect if the user closes his browser? need to change his log status on a back-end database and if he closes the browser am worried that the status will never be updated to logged off? any of you know any tricks to avoid this? thanks
 
Server side scripting will never know what's going on with the client side. So you will need client-side scripting with javascript to do it... this can be done with "onUnload(do_something_or_call_a_thanks_window)", thanks windows could have some script to logoff in your back-end.

The trick here is to make the main window open a popup window (the thanks window) in order to issue your "logoff" script at server side.

hope this helps.
 
that is not a bad idea at all thanks dude
 
You (probably) can't guarantee that your end-users have Javascript switched on, that the thanks window won't be stopped by some popup-blockers, or that they don't just bang out of the site - say when a dial-up connection goes down or their PC has a power outage.

So in addition to Chacalinc's sensible solution, you should probably have some failsafe in there too - maybe logging somebody off automatically if you haven't heard from them for, say, 30 minutes.

-- Chris Hunt
 
hey thanks, yeah as a backup, i also asked the oracle forum(because we're using oracle 91 obviously :) ) if theres a way to have a field automatically update itself after a certain amount of time, thanks again
 
You could update a date/time field every time you get a request from a logged on user, to show the time when they were last active. Then have a procedure run every few minutes using DBMS_JOB that updates any user who is supposedly logged on, but has been inactive for more than x minutes.

-- Chris Hunt
 
now that is a great idea, thanks a lot, just hope it wont be too much of an overhead on the system, thanks again dude
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top