note 70235 deleted from function.session-start by peehaa

From: Date: Fri, 09 Dec 2016 22:07:01 +0000
Subject: note 70235 deleted from function.session-start by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208324@lists.php.net to get a copy of this message
Note Submitter: evil dot 2000 at web dot de ---- I had a problem accessing a session which is open in another frame at the same time. I had a frame, which is displaying a live text like a chat. It has an opend and locked session. I tried to add data to this session with another frame, but this wouldn't work. In the first frame i had a loop which is looking for fresh data in the session and prints it out like this: <?php session_start(); [...] while (true) { echo $_SESSION["input"]."\n"; sleep(1); } ?> But this locks the session, and no other frame can access the session data at the same time. So i modified this loop a bit like this: <?php session_start(); [...] session_commit(); while (true) { ob_start(); session_start(); ob_end_clean(); echo $_SESSION["input"]."\n"; session_commit(); sleep(1); } ?> Now the second frame is able to access the session. The ob_start() and ob_end_clean() is just for surpressing the cookie output to the browser.

« previous php.notes (#208324) next »