> Something like this (but it doesn't work)
window.onbeforeunload = function() {
var msg = "===============================================\n \n\n";
msg+= "For security reason exiting from this page will cause you
cannot enter anymore in this url because of uniqueness of this action.
Continue?\n\n\n.";
msg+= "============================================= ==";
return msg;
// If "OK" will be clicked then I have to save informations.
}
If OK clicked then the browser gets closed. Otherwise it would be too
easy to create non-closable windows - on each onclose it would just run
another long process.
You cannot do anything really reliable with JavaScript (except setting
up cookies, what wrong with it by the way?).
Usually one goes from the opposite direction: upon login server creates
user's session file. On each call (step 1, 2, 3, n) server updates the
session file, so it always keeps the state of the last *successfull*
operation. This way your users can close the window, press computer
reset button, pull coffee inside the system block, dance lambada on
keyboard, yours to continue... But the session info is always secured
on the server.
Otherwise:
window.onbeforeunload = function() {
// try to save session info
// in hope that you'll get your chance for it
}