Jump to content

Need Advice


aruns

Recommended Posts

They're used if you need to control processing if a user clicks stop while a transaction is being processed, or if a transaction times out.

 

Typically you might set a shutdown function using register_shutdown_function().

If you've set a shutdown handler, then it will be executed whenever a script terminates, eithe rbecause it has completed successfully, because the user has hit abort in his browser, or on a script timeout.

Within that shutdown function, you can use connection_aborted(), connection_status() or connection_timeout() to determine why the script has finished, and perform some appropriate action.

 

I log such events using something like:

function say_goodbye() {
if (connection_aborted()) {
	$log = fopen('/usr/local/apache/logs/timeout_cli.txt','a');
	fwrite($log,gmdate('d M Y H:i:s').' - '.$_SERVER["HOSTNAME"].' --> '.$requestMode.' script for clients '.$requestClass.' at '.$requestMethod.' aborted'."\n");
	fclose($log);
} elseif (connection_status() == CONNECTION_TIMEOUT) {
	$log = fopen('/usr/local/apache/logs/timeout_cli.txt','a');
	fwrite($log,gmdate('d M Y H:i:s').' - '.$_SERVER["HOSTNAME"].' --> '.$requestMode.' script timeout for clients '.$requestClass.' at '.$requestMethod."\n");
	fclose($log);
}
}

register_shutdown_function("say_goodbye");

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.