📜 ⬆️ ⬇️

session_write_close () can be your friend

Once I ran into such a problem: on the website page using a PHP script, the user was given video content (see my article on “flash video on web pages and PHP” ).

The “giving up” video script worked for a long time (about the same as the video clip lasted: we set the download speed control according to the bitrate). So, if during the period of watching the video you opened a new tab in the browser with another page of the same site, an error occurred.

Casket opened quite simple. The site used authorization based on standard PHP sessions. So, when the session starts, the session file is locked, and until the session closes and the file is unlocked, no one can open the session file. By default, the session is closed at the end of the script. We added the session_write_close () line just before the video content was issued - voila, it all worked.
')
Since quite recently a friend complained about the exact same problem and was glad to receive a hint - I decided to share this “hint” with the habra people.

Source: https://habr.com/ru/post/37206/


All Articles