[nycphp-talk] Asynchronous downloads -- how?

Dan Cech dcech at
Wed Sep 5 15:47:31 EDT 2007

Kenneth Downs wrote:
> Let's say you have a link on a page,
>, which is actually being handled
> by a PHP file that checks for subscription status and then sends the
> file.  It looks like a straight download to the user.  So far so good.
> Now let's say the file is 50MB, so that a download will take several
> minutes.
> When the user initiates the download, and then attempts to go to another
> page on the site, they cannot.  All access to the site is waiting until
> the download completes.

This may be an over-simplification, but are you using
session_write_close() after the authentication phase is complete?

If the session is still active during the download, other requests with
the same session id will hang while php waits for your download script
to release the lock on the session file.

Calling session_write_close() will end the session and relinquish the
locks, allowing your other scripts to run.


More information about the talk mailing list