php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34862 Variable's session data cannot be modified
Submitted: 2005-10-13 23:12 UTC Modified: 2005-10-13 23:44 UTC
From: Lhunath at Pandora dot Be Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.0.5 OS: Linux Gentoo
Private report: No CVE-ID: None
 [2005-10-13 23:12 UTC] Lhunath at Pandora dot Be
Description:
------------
After a variable has been stored in the session file, it's content is available and visible in the file.
However, when later the variable's content is altered; the file's content is not. It remains the same initial value.
Because of this, the modification is lost.

(the session file can be altered in this way:
new variables can be added with their value.

the session file cannot be altered in this way:
existing variables in the file cannot have their value changed)

Reproduce code:
---------------
Avaria tmp # cat page1.php 
<?php
    session_start();
    $_SESSION["test"] = "1";
?>
<a href="page2.php?t=2">go to page 2</a>

Avaria tmp # cat page2.php 
<?php
    session_start();
    if($t) $_SESSION["test"] = $_REQUEST["t"];

    echo $_REQUEST["t"];
    echo $_SESSION["test"];
?>
<a href="page3.php">go to page 3</a>

Avaria tmp # cat page3.php 
<?php
    session_start();

    echo $_SESSION["test"];
?>

Expected result:
----------------
go to page 2

22go to page 3

2

Actual result:
--------------
go to page 2

21go to page 3

1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-13 23:21 UTC] tony2001@php.net
Remove this:
if($t) 
or use 
if($_GET['t']) 
instead and it'll work.
 [2005-10-13 23:41 UTC] Lhunath at Pandora dot Be
You are entirely correct; my example seems to not suffer from this issue, I just made a mistake in the code.
However; I posted it due to a problem I encountered in my own website. I seem to have failed to isolate the problem.

If you go to this page:
http://riello.lyndir.com/?lang=nl

you will see a page in Dutch (NL). Pressing the top right button "Francais", the page will change to French (FR). This will happen through the variable "lang" which is set to "fr" using GET. The page will be French. Mark that in the red debugging output you can see that in the variable $_SESSION  [lang] => fr.

When you click a link on the navigation bar now, the value "fr" of the variable "lang" is lost and reset to "nl" - the original. Should you originally use a different value for lang - "en" for example; it will restore the value to "en" after having clicked a random link on the french page. (The page is only available in French or Dutch).

I will continue an attempt to isolate the issue.
 [2005-10-13 23:44 UTC] tony2001@php.net
>I will continue an attempt to isolate the issue.
No problem.

Feel free to reopen the report when you get the real reproduce script.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 22:01:33 2024 UTC