php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42308 objects and variable together in session mix up the $_SESSION
Submitted: 2007-08-15 12:43 UTC Modified: 2007-08-15 17:24 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: domnuprofesor at yahoo dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.4.7 OS: Fedora Core 6
Private report: No CVE-ID: None
 [2007-08-15 12:43 UTC] domnuprofesor at yahoo dot com
Description:
------------
I came across this situation:
I had and object named "grid" which was a wrapper for a table.
In $_SESSION I already had a mysql singleton wrapper.
I tried to set another session variable with the key "grid1" and value, lets say "text". The result I got was that PHP loaded the object "grid1" in $_SESSION.
After I changed the key name, let say "grid1_text" I got the expected results!

Reproduce code:
---------------
$grid1 = new GridPrototype();
$grid1->setPerPage(4);
$grid1->setID("1");	
$grid1->setKey();

$id = "1";
$key = "grid" . $id;
$_SESSION[$key] = $status;



Expected result:
----------------
I expect to have the $status variable accessible via $_SESSION['grid1']

Actual result:
--------------
$_SESSION['grid1'] points to the object $grid1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-15 13:01 UTC] domnulnopcea at yahoo dot com
yes..i came across the same problem...

I did not even put the object in $_SESSION and it was there!!!!
 [2007-08-15 17:24 UTC] johannes@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

Looks like register_globals is activated on your host. Please see the documentation for more information about register_globals.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 03:01:30 2024 UTC