note 89177 modified in features.connection-handling by danbrown

From: Date: Wed, 25 Feb 2009 14:06:34 +0000
Subject: note 89177 modified in features.connection-handling by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151107@lists.php.net to get a copy of this message
A simple but useful packaging of arr1's suggestion for continuing processing after telling the the browser that output is finished. I always redirect when a request requires some processing (so we don't do it twice on refresh) which makes things easy... <?php function redirect_and_continue($sURL) { header( "Location: ".$sURL ) ; ob_end_clean(); //arr1s code header("Connection: close"); ignore_user_abort(); ob_start(); header("Content-Length: 0"); ob_end_flush(); flush(); // end arr1s code session_write_close(); // as pointed out by Anonymous } ?> Of course this wont work if the output has started - but the a simple redirect wouldn't work anyway. Thanks for the tip arr1 --was-- A simple but useful packaging of arr1's suggestion for continuing processing after telling the the browser that output is finished. I always redirect when a request requires some processing (so we don't do it twice on refresh) which makes things easy... function redirect_and_continue($sURL) { header( "Location: ".$sURL ) ; ob_end_clean(); //arr1s code header("Connection: close"); ignore_user_abort(); ob_start(); header("Content-Length: 0"); ob_end_flush(); flush(); // end arr1s code session_write_close(); // as pointed out by Anonymous } Of course this wont work if the output has started - but the a simple redirect wouldn't work anyway. Thanks for the tip arr1 http://php.net/manual/en/features.connection-handling.php

« previous php.notes (#151107) next »