|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3897 Can't register to a session from within an object
Submitted: 2000-03-22 12:00 UTC Modified: 2002-09-30 20:05 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ronen at greyzone dot com Assigned:
Status: Not a bug Package: Misbehaving function
PHP Version: 3.0.15 OS: RedHat Linux6.1
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.
Block user comment
Status: Assign to:
Bug Type:
From: ronen at greyzone dot com
New email:
PHP Version: OS:


 [2000-03-22 12:00 UTC] ronen at greyzone dot com
When I try to register a variable to a session from within a class all I get is a variable name with no value associated with it. 
I have an initial file which looks like this: 
class DOG{} 

class USER{ 
  function USER(){ 
  $tmp=new DOG(); 

$dog=new User(); 
echo "How's about it."; 

Then on a different page I have: 
echo $tmp->test. "<BR>"; 
echo session_id(); 

the only thing echoed out is the PHPSESSID value. 
when I go and take a look at the session file I see no value: 
>more sess_afb860c13c89fd697ad261ab8372e184 

This problem doesn't happen when I attempt to register from outside a class. Here's an example of what DOES work:
file noclass.html: 
class DOG{ 
var $name; 

$mydog=new DOG(); 
echo "session id: ".session_id()."<br>n"; 
echo "My dog's name is".$mydog->name."<br>n"; 
echo "is mydog registered? ".session_is_registered("mydog"); 

and the the next file noclass2.html: 
class DOG{ 
var $name; 

echo "session id: ".session_id()."<br>n"; 
echo "mydog's name is: ".$mydog->name."<br>n"; 

The output is as follows: 

session id: 7713588e3fbce54b0760c8a082fd5cc3 
My dog's name ispoochy 
is mydog registered? 1 


session id: 7713588e3fbce54b0760c8a082fd5cc3 
mydog's name is: poochy 

So, obviously an object CAN be stored to a session, but what is stored is only the data associated with the object properties. 

I return to my original question- why is it that an object can't be registerd to a session from within a class?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-30 20:05 UTC]
... 'cause you can only register variables 
from the global namespace and not from
variables local to functions or methods
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Aug 12 13:01:26 2020 UTC