php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35557 Non-scalar properties of objects stored in session variables aren't kept
Submitted: 2005-12-05 16:43 UTC Modified: 2005-12-06 10:56 UTC
From: fcardinaux at gmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5CVS-2005-12-05 (snap) OS: Windows XP Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fcardinaux at gmail dot com
New email:
PHP Version: OS:

 

 [2005-12-05 16:43 UTC] fcardinaux at gmail dot com
Description:
------------
Classes are defined in the file class.php. The class bar contains only one scalar property. The class foo contains three properties : an instance of the class bar, an array and a scalar property. 

In index.php, an instance of foo is stored in a session variable. Then the print_r function is called to display this variable's content. 
There isn't any bug at this point yet. 

By clicking on 'continue', you open the next file : verification.php. There, the print_r function is called again. 
As you can see, the content of the non-scalar properties of foo is lost. 

This is different from the behaviour of php versions until 5.0.5. 



Reproduce code:
---------------
www.cardinaux.info/session_problem_with_php_5_1_2_dev.zip

Expected result:
----------------
Verification.php should output : 

Foo Session Variable :
foo Object ( [_bar:private] => bar Object ( [_value:private] => 54321 ) [_names:private] => Array ( [0] => Boat [1] => Airplane [2] => Car ) [_value:private] => 1500 )


Actual result:
--------------
Verification.php outputs : 

Foo Session Variable :
foo Object ( [_bar:private] => [_names:private] => [_value:private] => 1500 )


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-05 20:39 UTC] fcardinaux at gmail dot com
I'm sorry, but it seems that this bug can't reproduce within a single script. Three php files are necessary : a class definition file (class.php, 61 lines), a start page (index.php, 47 lines) that links to a verification page (verification.php, 24 lines), where the bug appears. 

These files are enclosed in the archive 
www.cardinaux.info/session_problem_with_php_5_1_2_dev.zip.
 [2005-12-05 22:50 UTC] sniper@php.net
Don't store objects in sessions.
 [2005-12-06 10:56 UTC] fcardinaux at gmail dot com
I'm sorry to insist, but the documentation on php.net itself says it's possible to store objects in sessions, with two precautions : not to turn on session.auto_start, and not to store objects with circular references. 

Furthermore, the example I gave you worked until PHP 5.0.5.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 05:01:35 2024 UTC