note 106019 deleted from function.session-start by danbrown

From: Date: Mon, 03 Oct 2011 16:55:18 +0000
Subject: note 106019 deleted from function.session-start by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183614@lists.php.net to get a copy of this message
Note Submitter: VR46Fan ---- This comment may help others who keep losing session data. I'm running PHP 4.3.4 & IIS 6.0 (Windows 2003 server) This was the scenario I encountered: // Page1.php <?php session_start(); // other code $_SESSION['myObj']=serialize($myObj); // more code session_write_close(); // header redirect header("Location: Page2.php"); ?> // Page2.php <?php session_start(); // other code $myObj=unserialize($_SESSION['myObj']); // more code... session_write_close(); // <html> code for form // submit to Page2.php (itself) ?> When I submitted a form on Page2.php (to itself), it kept losing the 'myObj' data. What I ended up doing was: //Page2.php <?php session_start(); // other code $myObj=unserialize($_SESSION['myObj']); // process obj // set session variable again! $_SESSION['myObj']=serialize($myObj); session_write_close(); ?> Hope this helps someone.

« previous php.notes (#183614) next »