Hi there!
I'm looking for the right way to keep a session along all my website, giving the typical options (access to all the vars, check if it's alive, ...). The problem is that I know how to do it but I think that there must be a more smart way.
Now I'm doing this for the login:
PHP Code:
...
private $_userSession;
...
Zend_Session::rememberMe(100); // Give N life seconds to cookie
Zend_Session::start(); // It must be done to work with sessions.
// Always before any "new Zend_Session_Namespace()"
// Authentication adapter. Uses Zend_Session.
$storage = new Zend_Auth_Storage_Session();
$storage->write($adapt->getResultRowObject(array('id')));
$auth->setStorage($storage);
$storage->user = htmlspecialchars($params['user']);
// Use 'someNamespace' instead of 'Zend_Auth'
$ns = new Zend_Session_Namespace('DLM_user', true);
$ns->user = htmlspecialchars($params['user']);
$this->_userSession = $ns;
And this when I want to access the sessions values, from any other controller:
PHP Code:
...
private $_userSession;
...
$_userSession = new Zend_Session_Namespace('DLM_user');
$this->view->isLogged = $_userSession->user;
Thanks in advance!