Search code examples
zend-frameworkzend-auth

Session set for some Actions in Zend framework


I'm working on a website , in CV part users have some articles that only logged in users can download. I want to make changes to the login Action or preDispatch() to set session for guest users to download the articles.

Can someone tell me how it can be done or give me some reference links?

Here is my preDispatch():

   public function preDispatch()
    {
        $userInfo=$this->_auth->getStorage()->read();
        $identity= $this->_auth->getIdentity();
        if(!$this->_auth->hasIdentity())
        {

            return $this->_helper->redirector('login','login');


        }
        if(!isset($userInfo["member_id"]) || strlen($userInfo["member_id"])==0)
        {
            return $this->_helper->redirector('forbidden','login');
        }
        $this->_accessType=2;

    }

Solution

  • If you want different accessibility for guest users you should take a look at Zend_Acl. Here are two links that may help you: http://framework.zend.com/manual/1.12/en/learning.multiuser.authorization.html, Zend Auth and ACL.