|  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: None
 [2006-02-11 10:37 UTC] flummi at everymail dot net
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:

echo "Session 1:\n";

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

echo "Session 2:\n";

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 */


Add a Patch

Pull Requests

Add a Pull Request


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

Turn off register_globals if you don't want this behaviour.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC