Classes and sessions
| From: | Andrew Sterling Hanenkamp | Date: | Tue, 24 Jul 2001 13:34:30 +0000 |
| Subject: | Classes and sessions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-59344@lists.php.net to get a copy of this message | ||
I am having some trouble with storing a class in a session variable. According to the information in the manual, an object will be serialized at the end of each request and then unserialized at the beginning automatically. However, with this code:
<?php
session_register("objectvar", "stringvar");
if(isset($stringvar)) {
echo "stringvar is set\n";
} else {
$stringvar = "something";
echo "stringvar is not set\n";
}
if(isset($objectvar)) {
echo "objectvar is set\n";
} else {
$objectvar = new MyObject;
echo "objectvar is not set\n";
}
?>
For the first page I will get:
stringvar is not set
objectvar is not set
And for each subsequent page:
stringvar is set
objectvar is not set
Is there something wrong with the way my code works? Is this a possible bug? I have had this problem with both 4.0.4pl1 (came with RH7.1) and with 4.0.6 (compiled myself). I've been struggling with this for 3 or 4 days now and some help would be much appreciated.
Thanks,
Sterling