I need to kill the session when the user closes the browser or redirects into some other page. I can see the following options of achieving this functionality:
- Use no session login. It's not my case, because I'd have to change a lot and I also use sessions for some other data.
- I could use something like this:
window.onunload = window.onbeforeunload = (function () {
...
})
And from this code call the action that cleans the session and performs logoff. Sounds nasty but what is also important - this JavaScript code works only in IE.
- I could create some nasty code that uses some dummy calls, let's say every minute, just to say the server that the user is still alive. But it's really nasty. It would use useless load on the server, lots of useless calls and in the case if some call was lost(because of the connection issue or something) the user would logg off.
Any other options?