php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36366 session is changed when assigning local vars with same name as session
Submitted: 2006-02-11 10:37 UTC Modified: 2006-02-11 11:22 UTC
From: flummi at everymail dot net Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.4.2 OS: OSX
Private report: No CVE-ID:
 [2006-02-11 10:37 UTC] flummi at everymail dot net
Description:
------------
I am assigning a session var $_SESSION['name'] and then assign a local var $name, which overwrites the first session var when I reload the page.

NOTE: this bug only occours when reloading the page. It seams, that PHP has a reference $name = $_SESSION['name'] saved, the second time this script is executed. Am I missing anything??

Reproduce code:
---------------
$_SESSION['name']=array("One","Two");

echo "Session 1:\n";
var_dump($_SESSION['name']);

// the following line also changes $_SESSION['name']
// when the session was already set bevore (on reload)
$name = array();

echo "Session 2:\n";
var_dump($_SESSION['name']);


Expected result:
----------------
Session 1: array(2) { [0]=>  string(3) "One" [1]=>  string(3) "Two" } Session 2: array(2) { [0]=>  string(3) "One" [1]=>  string(3) "Two" }



/* the above result is displayed the first time, but when I reload the page... */

Actual result:
--------------
Session 1: array(2) { [0]=>  string(3) "One" [1]=>  string(3) "Two" } Session 2: array(0) { }



/* on reload, the above output is given */

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-11 11:22 UTC] tony2001@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Turn off register_globals if you don't want this behaviour.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC