ID: 33585
User updated by: piero dot mac at gmail dot com
Reported By: piero dot mac at gmail dot com
-Status: Bogus
+Status: Open
Bug Type: Session related
Operating System: WIN XP HOME sp2
PHP Version: 5.0.4
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2005-07-06 13:16:47] [EMAIL PROTECTED]
$_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.
------------------------------------------------------------------------
[2005-07-06 13:08:13] piero dot mac at gmail dot com
No errors or notices are displayed.
Im sorry, but right now, I don't have any available URL at this time.
Here you find all reproduced bug code:
pag1.php
<?php
$html = <<<EOD
<html><body><form action = "page2.php" method = "post">
name <input type="text" name="nick" value="pippo"><br />
city <input type="text" name="city" value ="Turin"><br />
<input type="submit" name="submit" value = "submit">
</form></body></html>
EOD;
echo $html;
?>
page2.php
<?php
session_start();
if(isset($_POST)) {
$_SESSION = $_POST; }
else {
$_POST = $_SESSION; }
echo "<pre>";
print_r($_POST);
print_r($_SESSION);
echo "<a href='bug2.php'>refresh</a>";
?>
------------------------------------------------------------------------
[2005-07-06 12:21:40] [EMAIL PROTECTED]
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc.
If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.
Can't reproduce.
Please set display_errors to On and error_reporting to E_ALL in your
php.ini and see if there are any error messages.
------------------------------------------------------------------------
[2005-07-06 11:58:27] piero dot mac at gmail dot com
Description:
------------
When using $_SESSION in order to transfer POST form informations to
others or to the same page with refresh, and data transfert from $_POST
to $_SESSION has done as the follow:
$_SESSION = $_POST;
No data session will be stored into session save data file.
Session file is empty.
This problem didn't exist to previous php releases.
Reproduce code:
---------------
<?php
session_start();
// any POST data incoming from FORM is true
if(isset($_POST)) {
$_SESSION = $_POST;
} else {
$_POST = $_SESSION; }
print_r($_POST);
print_r($_SESSION);
?>
Please, try to page refresh now
Expected result:
----------------
I'm waiting for the same value printed as the first time to any
following refresh.
Actual result:
--------------
Problem is possible to bypass with previus creation of empty $_SESSION
$_SESSION = array();
or to transfer to $_SESSION all values one by one (using foreach).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33585&edit=1