View Single Post
  #1 (permalink)  
Old 05-21-2008, 03:06 PM
eric.cat eric.cat is offline
Junior Member
 
Join Date: May 2008
Posts: 4
Default Sessions way of life

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!
Reply With Quote