Continue script execution on client disconnection
June 6th, 2006Jayant, I have written a PHP code to do some processing on data which should not be stopped by the user in between as it leaves the system in an invalid state. The problem comes when the user disconnects by either pressing the browser’s stop button or closes the browser window. Is there a way in PHP to define atomic functions or atomic scripts? I want the script or the function to execute completely or not at all. Thanks!
- Dale
To continue the script execution on client disconnection, you can use a function provided by PHP called ‘ignore_user_abort‘. This function sets whether on client disconnect, should script execution be continued or aborted. Calling the function with the parameter set to ‘TRUE’ should ignore user disconnection and continue with script execution.
When finished you may again set the value to ‘FALSE’ to allow the script to halt on client disconnect.
June 8th, 2006 at 10:44 am
Awesome, was wondering how I could do that.
Perfect!