php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37050 post variables appear in session
Submitted: 2006-04-12 09:38 UTC Modified: 2006-04-12 09:51 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: adrian dot carstea at gmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.1.2 OS: Fedora Core 4
Private report: No CVE-ID: None
 [2006-04-12 09:38 UTC] adrian dot carstea at gmail dot com
Description:
------------
post variables appear in session after 3 posts... 
$_GET
Array
(
)
$_POST
Array
(
    [search_didi] => asd
    [submitare] => Cautare simpla // !!!!!!!!!
    [submit] => Cautare           // !!!!!!!!!
)
$_SESSION
Array
(
    [submitare] => Cautare simpla // !!!!!!!!!
    [submit] => Cautare           // !!!!!!!!!
    [search_didi] => asd
)



Reproduce code:
---------------
Source code tested on php5.0.4, php5.1.2 (works fine on php4.4.0)
<?
session_start();

if(isset($_POST['submitare']) && ($_POST['submitare']=='Cautare simpla' || $_POST['submitare']=='Cautare avansata')){

        foreach($_SESSION as $key=>$value){
             if(preg_match("@_didi$@i",$key)){
                        unset($_SESSION["{$key}"]);
              }
        }
        foreach($_POST as $key=>$value){
                //echo $key."  ".$value."<hr>";
                if(preg_match("@_didi$@i",$key)){
                        echo $key."=".$value."<hr>";
                        $_SESSION["{$key}"]=$value;
                }
        }

}
echo "<pre>";
print_r($_GET);
print_r($_POST);
print_r($_SESSION);
echo "</pre>";
if(!isset($_POST['submitare']) && !isset($_GET['page'])){
        foreach($_SESSION as $key=>$value){
                if(preg_match("@_didi$@i",$key)){
                        unset($_SESSION["{$key}"]);
                }
        }
}
?>
<form action="" method="POST">
        Cauta: <input type="text" name="search_didi" value="" />
        <input type="hidden" name="submitare" value="Cautare simpla" />
        <input type="submit" name="submit" value="Cautare" />
</form>


Expected result:
----------------
$_GET
Array
(
)
$_POST
Array
(
    [search_didi] => asd
    [submitare] => Cautare simpla // !!!!!!!!!
    [submit] => Cautare           // !!!!!!!!!
)
$_SESSION
Array
(
    [search_didi] => asd
)




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-12 09:51 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 25 21:00:02 2025 UTC