Create a function (check_abort()) that writes a log message when the client aborts the script:
<?phpfunction check_abort() { if (connection_aborted()) error_log ("Script $GLOBALS[SCRIPT_NAME]" . "$GLOBALS[SERVER_NAME] was aborted by the user."); }// Some script to be executed here// Call the check_abort function when the script endsregister_shutdown_function("check_abort");?>The connection_aborted() function checks whether the client is disconnected.
connection_aborted()
Return value: | Returns 1 if the connection has been terminated, 0 otherwise. |
---|---|
PHP version: | 4+ |