Ford, Mike wrote:
>> -----Original Message-----
>> From: Peter Ford []
>> Sent: 20 November 2009 15:18
>> To:
>> Subject: [PHP] Does PHP block requests?
>> I have a tricky problem.
>> I'm trying to make a progress feedback mechanism to keep users
>> informed about a
>> slowish process on the server end of a web app. The backend is
>> generating a PDF
>> file from a bunch of data which extends to many pages. I can keep
>> tabs on the
>> progress of this generation by working out how many lines of data is
>> present,
>> and how much of it has been processed. I use that information to set
>> a session
>> variable with a unique name - so for each step I set
>> $_SESSION['some-unique-
>> name']=>Array('total'=>$totalLines,'count'=>$linesProcessedSoFar);
> The progress-counter Ajax script uses a session -- but does the PDF generator 
> use the same session? If so, I'm guessing you don't manually close the 
> session at any point and all the progress-checking calls are blocked until 
> the session auto-commits at the end of the generator script. To counter this, 
> you need to manually session_commit() somewhere near the beginning of the 
> generator script.
> Cheers!
> Mike
>  -- 
You're right about trying to use the same session - that was the plan to get the
progress state passed across from one call to the other.
Closing the session on the generator script has the effect of stopping any
further changes to the session variable, so I get the initial value at each
request after that.

I put together a simple "Generator" script to test this:

header("Content-type: text/xml");
$fcode = 'foo';
for ($i=0; $i<10; $i++)
echo "<p>Done</p>";

and the code for the progress backend is like this:
$code = 'foo'
if (isset($_SESSION[$code]['count']) && isset($_SESSION[$code]['total']))
 header("Content-type: text/xml");

What I get now is that the session variable is set to 1 out of 10, but never
changes after that.

Perhaps I can do it with some other message passing mechanism (e.g. a temporary
file) instead of the $_SESSION.
Thanks for you help so far...



Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to