Reputation: 1637
I am very new to this Zend_Session thing. I do have a Zend Framework App running; now I want to add some "features" to it. One of that features requires some data contained in a Session, so it is stored over all sites, the user will visit.
In my Bootstrap, I have
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initSession() {
Zend_Session::setOptions(array(
'use_only_cookies' => 'on',
'remember_me_seconds' => 864000
));
Zend_Session::start();
}
}
In my model, there is a function that stores data into the $_SESSION for a given keyword:
$_SESSION['foo'][urlencode($keyword)] = array(
'data' => $base->some->foo[0]->fish->data
);
The new data is only set to session, if the session-key (with the keyword) is not set. I checked that with zend debugger, all is running well.
Now, when I call the page first, all's running well. When I reload the page (or move to another), the values in the Session are gone. So, to be exact, the keys are there, the $_SESSION Array is (for example) 20 entries of size. There is an entry, but it is null.
$_SESSION['foo']['my+foo']['data'] = null
When I call:
Zend_Debug::dump($_SESSION['foo']['my+foo']);
I get:
array (size=1)
'data' => null
So, it is there and it had killed my value.
What is the magic voodoo to get it running like when I use a simple session_start()?
Upvotes: 0
Views: 496
Reputation: 1637
drew010 made it, i have to save every single value to it's representation to my session, so
$_SESSION['foo']['bar'] = array(
'data' => (int) $base->some->foo[0]->fish->data,
'moredata' => (string)$base->some->foo[0]->fish->moredata
);
and so on. Thanks!
Upvotes: 0
Reputation: 6202
Press Ctrl + F and replace everything with the Zend_Session_Namespace
object instead of the super global $_SESSION:
$session = new Zend_Session_Namespace('foo');
$session->someData = array(
'data' => array('blah')
);
If the error continues, extends the Zend_Session_Namespace
and put an echo
(for debug) whenever you change the session data, then you'll be able to know if it's being replaced by another piece of code without your acknowledgement.
Or better, use an interactive debugger and inspect the class line by line (i.e. xDebugger). That one never fails ;)
Upvotes: 1