Reputation: 31
I'm looking for a well-supported way to capture a user leaving a page -- by typing in a new URL, clicking a bookmark, etc. -- to destroy the session so that a person cannot use the 'back' button to return to the site logged in.
Searches have turned up body onbeforeunload=...
, an IE-ism that is supposedly supported by other current browsers, but is there a better or more official browser- and server side technology-neutral HTML/JavaScript way to do this?
Upvotes: 2
Views: 388
Reputation: 41246
The only way to do that, imo, is to use a keep alive on a short leash from your site. I.E. do an ajax keep alive to the server to keep your session active, and if they browse away, the keep alive disappears and thus the session expires. Kinda a brute force method though...
Upvotes: 1