I'm struggling with object persistence in sessions...sorry if this is a
newbie question, but couldn't find answers in the archives...

Basically, I'm loading my namespace session vars; then in my action, I check
if an object exists in the session vars, and if so assign a local reference
to it.  If the object isn't in the session vars, I create a new one in the
session vars and setup a local reference.

>From testing it appears that I am able to persist non-objects in the session
vars (ie. I can restore an int), but my object isn't persisting between
requests.  My include path for the class ('Album') is ok since I can
instantiate the object in my code without error.

public function listAction()
{
//load collection vars from session
$sessionVars = new Zend_Session_Namespace('collection');

//get album from session or create new one
if (isset($this->sessionVars->album))
        {       
                $currentAlbum = $sessionVars->album;
        }
else
        {
                $sessionVars->album = new Album();
                $currentAlbum = $sessionVars->album;
        }
}

Is there more to "defining the object before the object is unserialized from
session storage" (from docs) than ensuring the class definition is found in
the include path?
-- 
View this message in context: 
http://www.nabble.com/Zend-Session-and-objects-tp20308552p20308552.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to