I am trying to save an object in $_SESSION , but the following:
<?php $user = db->load( $username, $pass ) ; $_SESSION[ 'user' ] = $user ;
Unfortunately this does not work.
The script tried to execute a method or access an object of an incomplete object. Make sure that the definition of the User class of the object you are trying to work with is loaded, _before_ unserialize () is called or provides the __autoload () function to load the class definition
If you are not using serialize ():
<?php $user = db->load( $username, $pass ) ; $_SESSION[ 'user' ] = serialize( $user ) ;
I suppose it will need to be serialized because session information is stored on disk. But shouldn't PHP be smart enough to serialize stuff on its own?
And using serialize / _ unserialize_, will this work reliably now? Or do I need the __serialize() method in my PHP class?
php serialization session
bobobobo
source share