note 69630 added to function.session-start

From: Date: Wed, 13 Sep 2006 12:42:03 +0000
Subject: note 69630 added to function.session-start
Groups: php.notes 
Request: Send a blank email to php-notes+get-117097@lists.php.net to get a copy of this message
Recursive session usage isn't possible. By that I mean fetching (via curl or such) another page on the site which uses sessions, as part of a page which itself uses sessions. For example: page1.php: <?php session_start(); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "http://example.com/backend.php"); curl_exec($curl); ?> backend.php: <?php session_start(); print $_SESSION['foo']; ?> In this case, requesting page1.php will hang the request indefinitely. backend.php is waiting to open the session data for reading/writing, but it's still locked by page1.php, which is waiting for backend.php to finish. Because there's no session_end(), you can't get PHP to relinquish the lock on the session data after session_start() has occured. The solution is just to include backend.php or its functionality directly, e.g.: require './backend.php'; ---- Server IP: 83.138.144.80 Probable Submitter: 195.173.23.111 ---- Manual Page -- http://www.php.net/manual/en/function.session-start.php Edit -- https://master.php.net/note/edit/69630 Del: integrated -- https://master.php.net/note/delete/69630/integrated Del: useless -- https://master.php.net/note/delete/69630/useless Del: bad code -- https://master.php.net/note/delete/69630/bad+code Del: spam -- https://master.php.net/note/delete/69630/spam Del: non-english -- https://master.php.net/note/delete/69630/non-english Del: in docs -- https://master.php.net/note/delete/69630/in+docs Del: other reasons-- https://master.php.net/note/delete/69630 Reject -- https://master.php.net/note/reject/69630 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117097) next »