tags:

views:

54

answers:

3

how can i update a table when a user close the page or exit from that page..................

+1  A: 

If there's pending AJAX calls you can ask the user to stay on the page by listening for the onbeforeunload event. Ultimately the user can choose to interrupt whatever pending processing needs to be done, either by navigating away, closing the window, killing the browser process, experiencing a computer crash, etc. You application should be robust enough to handle these situations.

pygorex1
+2  A: 

You can have some kind of periodic timer server-side, which resets for each request. If that timer passes the session lifetime, then the user is no longer active, and you can do whatever you need to do.

Tor Valamo
A good answer, but I don't think it will work for what the OP is trying to do (based on their comment on another answer).
Blair McMillan
+3  A: 

You can't (directly). You could however attempt to make a JavaScript unload event call (via Ajax) to the server which would then trigger the required MySQL activity.

However, you can't really rely on this happening reliably (not everyone has JavaScript installed, etc.)

What problem are you attempting to solve?

middaparka
i want to make a user login logout alert just like msn messenger........
Web Worm
Do you mean a 'This user is already logged in' style message? If so, see http://stackoverflow.com/questions/247412/
middaparka