Page 1 of 1

assigning class object as a session variable HELP!

Posted: Tue Apr 06, 2004 5:25 pm
by bg
I'm trying to pass along a class object as a session variable, and I'm not having much luck.

basically I have

Code: Select all

include ('cClass.class.php');

session_start();
if (!empty($_SESSIONї'obj']){
unset($_SESSIONї'obj']);
}

$obj = new cClass('construct it');

$_SESSIONї'obj'] = $obj;
then in a seperate script

Code: Select all

include ('cClass.class.php');

$obj = new cClass(); //added this line because i was getting an error about instantizing a class object before its been defined or something

session_start();
$obj = $_SESSIONї'obj'];


echo $obj->get_something();
Basically, my code is acting like $obj is a class without any values assigned within it. Its like its brand spankin new. What am I doin wrong here?

Posted: Tue Apr 06, 2004 5:33 pm
by markl999
The code works fine for me (though i didn't need the $obj = new cClass(); that you have in the second script).
Do sessions in general work ok for you, or just this particular script?