Possible Duplicate:
Detect browser connection closed in PHP
There are times where I must use something like this:
set_time_limit(0);
// User is uploading some large data
// ...
// Done uploading, from now on processing must be finished, no matter what
ignore_user_abort(true);
// Process the uploaded data...
while (reading the data) {
// ...
}
The problem is, there are cases where I need to know when user cancel/close the browser window (while I'm still processing the data), so that I can do some db sync/cleanup
I read about register_shutdown_function
, but it seems not the way to go, I need a reliable indicator that tells that user is gone, not just a shutdown notification, ie.
// Process the uploaded data...
while (reading the data) {
if (user_closed_window == true) {
CleanUp();
break;
}
}