0

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?

Ashwin
  • 847
  • 1
  • 6
  • 5

1 Answers1

2

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

janmoesen
  • 7,910
  • 1
  • 23
  • 19
  • Thanks. Is there any other way of calling the session cleanup function in server when this happens? – Ashwin Jun 03 '10 at 11:28
  • 1
    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 Jun 03 '10 at 11:32