Best way to deal with session handling in Zend Framework

Posted by JACK IN THE CRACK on Stack Overflow See other posts from Stack Overflow or by JACK IN THE CRACK
Published on 2010-03-24T01:59:32Z Indexed on 2010/03/24 2:03 UTC
Read the original article Hit count: 376

So I'm starting up in Zend framework and looking to implement a site-wide "User" session.... something I can easily access from ALL modules/controllers in the application.

I'm like, should I make a new namespace in the library and extend the controller, like:

MyLib_Controller_Action extends Zend_Controller_Action
{
    protected $_userSession;

    function preDispatch(Zend_Controller_Request_Abstract $req)
    {
         $this->_userSession = new Zend_Session_Namespace('user');
    }
}

ANd then have all my controllers/modules/etc extend from that?

Or should I create a Plugin or what? How would you go about making this plugin to pass the user session to the controller?

Or do I do it in the bootstrap?? Again how to pass to controller?

Also should I use Zend_Session_Namespace or Zend_Http_Cookie and also how do I encrypt and xss clean the cookie or is that did automagically?

© Stack Overflow or respective owner

Related posts about zend

Related posts about php