[thelist] [PHP Newbie] Accessing Object attributes from a _SESSION variable
Tanner
tanner at you.okstate.edu
Wed Oct 29 17:16:47 CST 2003
> Thanks, John, that did the trick. I also found another method of
> accomplishing that same serialization when dealing with objects in sessions:
>
> register_session("person");
...
> Do any of you know if there's any sort of advantage / disadvantage to
> accessing the session variables this way, as opposed to...
>
> $_SESSION["person"] = serialize($person); //when writing
>
> and
>
> $person = unserialize($_SESSION["person"]); //when reading
>
> ..?
>
> I'd be interested in hearing your comments on this. Thanks!
>
> -jacques :)
> --
The disadvantage is that session_register relies on register globals,
and is thus deprecated. The recommended way is the second way dealing
with the super global array $_SESSION. If you plan on using objects a
lot in sessions writing a helper class seems as if it would make things
a lot easier but maybe thats just me.
Tanner Burson
More information about the thelist
mailing list