note 101452 added to function.session-start
| From: | dave1010 at gmail dot com | Date: | Fri, 17 Dec 2010 09:35:59 +0000 |
| Subject: | note 101452 added to function.session-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175015@lists.php.net to get a copy of this message | ||
PHP locks the session file until it is closed. If you have 2 scripts using the same session (i.e.
from the same user) then the 2nd script will not finish its call to session_start() until the first
script finishes execution.
If you have scripts that run for more than a second and users may be making more than 1 request at a
time then it is worth calling session_write_close() as soon as you've finished writing session
data.
<?php
// a lock is places on the session, so other scripts will have to wait
session_start();
// do all your writing to $_SESSION
$_SESSION['a'] = 1;
// $_SESSION can still be read, but writing will not update the session.
// the lock is removed and other scripts can now read the session
session_write_close();
do_something_slow();
?>
Found this out from http://konrness.com/php5/how-to-prevent-blocking-php-requests/
----
Server IP: 69.147.83.197
Probable Submitter: 213.208.116.72
----
Manual Page -- http://www.php.net/manual/en/function.session-start.php
Edit -- https://master.php.net/note/edit/101452
Del: integrated -- https://master.php.net/note/delete/101452/integrated
Del: useless -- https://master.php.net/note/delete/101452/useless
Del: bad code -- https://master.php.net/note/delete/101452/bad+code
Del: spam -- https://master.php.net/note/delete/101452/spam
Del: non-english -- https://master.php.net/note/delete/101452/non-english
Del: in docs -- https://master.php.net/note/delete/101452/in+docs
Del: other reasons-- https://master.php.net/note/delete/101452
Reject -- https://master.php.net/note/reject/101452
Search -- https://master.php.net/manage/user-notes.php