Edit report at http://bugs.php.net/bug.php?id=33585&edit=1
ID: 33585 Comment by: thomas dot garbler at yahoo dot com Reported by: piero dot mac at gmail dot com Summary: Session saved file empty. Status: Bogus Type: Bug Package: Session related Operating System: WIN XP HOME sp2 PHP Version: 5.0.4 New Comment: I admit, the problem is here. PHP v5.1.2 (Apache v2.2.0 with "mass virtual hosting") empty session file. I'm trying to install UebiMiau v2.7.11 webmail system. It took me two days to understand what's going on. $_SESSION gets modified correctly even using references but never get written to session file. also the sample provided by "piero dot mac at gmail dot com" works as stated, i.e. $_SESSION isn't working as expected. Previous Comments: ------------------------------------------------------------------------ [2005-07-06 14:40:00] piero dot mac at gmail dot com Ok. Maybe it's my fault don't explain very well the problem. I try again ... the last. Forget $_POST. Find here another example: Page1.php <?php session_start(); $_test = array('one'=> 'first','two' => 'second', 'last'=>'last'); $_SESSION = $_test; echo "<pre>"; print_r($_test); print_r($_SESSION); echo "<a href='page2.php'>to page 2</a>"; ?> page2.php <?php session_start(); echo "<pre>"; print_r($_SESSION); ?> $_SESSION in page2.php is empty. It's no good. try now another one. Page1_a.php <?php session_start(); $_test = array('one_a'=> 'first','two_a' => 'second', 'last_a'=>'last'); foreach($_test as $key => $value) { $_SESSION[$key] = $value; } echo "<pre>"; print_r($_test); print_r($_SESSION); echo "<a href='page2.php'>to page 2</a>"; ?> now $_SESSION is correctly full. I repeate once again... before rel. 5.0.4 never happen this problem. Nothing to do with POST, isset() or empty(). Only it was the more lighting problem for me. Thnx for the attention and best regard. ------------------------------------------------------------------------ [2005-07-06 13:28:55] tony2...@php.net Read carefully my last comment. Change isset() to !empty() and see that it works perfectly. ------------------------------------------------------------------------ [2005-07-06 13:26:32] piero dot mac at gmail dot com ref. $_POST is always set, it's just empty when there is no POST data. So it comes that you set _SESSION to empty array(). No bug here -> bogus. Problem is not POST of course is empty after refresh page. Problem is "NO DATA had stored in session save file". you can try also: if(isset($_POST) && !empty ($_POST)) { Php 5.0.3 and previoulsy are true. Thanx any way... ------------------------------------------------------------------------ [2005-07-06 13:19:49] piero dot mac at gmail dot com Sorry, but I see a refresh link error in page2.php Last line is href = "page2.php" and not href=bug2.php.... page2.php <-- correct version, thanx. <?php session_start(); if(isset($_POST)) { $_SESSION = $_POST; } else { $_POST = $_SESSION; } echo "<pre>"; print_r($_POST); print_r($_SESSION); echo "<a href='page2.php'>refresh</a></pre>"; ?> After page refresh $_SESSION is empty and any session data stored in session save file. ------------------------------------------------------------------------ [2005-07-06 13:16:47] tony2...@php.net $_POST is always set, it's just empty when there is no POST data. So it comes that you set _SESSION to empty array(). No bug here -> bogus. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=33585 -- Edit this bug report at http://bugs.php.net/bug.php?id=33585&edit=1