I am trying to find a method to execute some PHP code once a user closes the page. In my application, once the user closes or navigates away from the page the server will st
Simply set ignore_user_abort(true) then enter an infinite while loop of
while (!connection_aborted()){
// do nothing ...
}
//after the while loop :
some_function_to_say_that_the_user_is_offline();
but be carefull , whenever the user navigates out of the page , the function WILL be executed .
EDIT : and the progress bar of the browser will be like "downloading ..." forever ...
Edit 2 : check also http://www.php.net/manual/en/function.register-shutdown-function.php