views:

25

answers:

1

Hi,

I hav onUnload="cleanup()" defined in my html body tag. The cleanup() method in javascript is

function cleanup() {--clean up session--}.

But when the browser is terminated by killing the process using task manager, I want to do the same action as cleanup. How can this be done?

+2  A: 

You cannot. If the process is forcefully killed, nobody cares about your scripts.

janmoesen
Thanks. Is there any other way of calling the session cleanup function in server when this happens?
Ashwin
That depends on what your "session cleanup function" does. If it is client-side code: no. If it is an Ajax-y request to a server script that performs some function: yes, depending on your session management. Look at a Cron job that performs the clean-up for sessions that have timed out.
janmoesen
Thanks for the info.
Ashwin