I am using CURL to download a large file from an external url and save it on my server. This can take up to few minutes. While the download is running I'm using the curl_setopt($ch, CURLOPT_PROGRESSFUNCTION,.. to run anonymous function which periodically updates my $_SESSION['download_progress'] variable with current download info.
Now, all this is happening in upload.php file and while the user is waiting for the file to download I use javascript to request progress.php page which contains the following simple code:
session_start();
echo $_SESSION['download_progress'];
This allows my javascript code to display information about the download progress.
Except it's not working.
The "progress.php" page won't load until the "upload.php" finished loading (in other words both pages load only after the file finished downloading) and this, is not good. The session_start() somehow blocks the "progress.php" page from loading. I use my own server (apache + php 5.4) so I have all admin rights.
How can I solve this problem? I could use some ugly workaround, like writing the download information into a text file instead of session variable and then use the javascript to directly read that text file, but I would rather not do that.
Thanks