tags:

views:

30

answers:

1

I have an application on an Apache2. The applications plays some media files like video files, mp3 files and wav files using a php file in order to avoid direct download from not-registered users. Now, I'm having problems because during the media file is loading, I cannot go to another page on the application until the media file is fully loaded.

I don't know if it's an issue about Apache2 or PHP. Can anybody help me to find out a solution for this issue? It seems that the same client cannot load two instances of PHP pages in the same site.

I'm looking forward your answers. Thanks in advance

+3  A: 

If you are using session, I suggest you session_write_close() before you output the file to the browser.

This is because when the session is opened on one page, you cannot load another page until the session has been written and released. session_write_close() is called automatically when your script ends, but because your outputting process takes time before your script end, your session file is locked and thus other pages cannot be viewed.

However, if you are using different browser and/or system, it will be ok because the session file locked is unique to each SESSION ID.

Look at: http://php.net/manual/en/function.session-write-close.php

However do take note that after session_write_close(), you cannot call session_start() or there will be an E_WARNING warning. Also if you make changes to $_SESSION, it will not take effect.

thephpdeveloper
glad that helped!
thephpdeveloper
Thanks a lot for your quick and right answer. That fix the problem.
Fran García