Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-21-2008, 03:06 PM
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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-21-2008, 05:58 PM
Junior Member
 
Join Date: Mar 2008
Posts: 26
Default

PHP Code:
$auth Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session()); 
and everything writes automatically :P the you can retrieve the stored user data, read on more in manual
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:47 AM.