examples/retwitter/application/controllers/UserController.php
public function loginAction()
    {
        $form = new Form_UserLogin;
        
        if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
            $auth = Zend_Auth::getInstance();

            $options = array(
                'userIdKey'   => 'userIdKey:*',
                'userDataKey' => 'users:*',
                'userDataIsArray' => true
            );
            $adapter = new Rediska_Zend_Auth_Adapter_Redis($options);

            // Set login and password
            $adapter->setIdentity($form->getElement('login')->getValue())
                    ->setCredential($form->getElement('password')->getValue());
                    
            // Authorization
            $result = $auth->authenticate($adapter);
            if ($result->isValid()) {
                $userData = $adapter->getResultUserData();

                $session = new Zend_Session_Namespace('Zend_Auth');
                
                $storage = $auth->getStorage();
                $storage->write($userData);
                
                $this->_redirect('/post/index/');
            } else {
                $form->getElement('login')->addError('Wrong login/password combination');
            }
        }
        
        $this->view->form = $form;
    }
public function loginAction()
    {
        $form = new Form_UserLogin;
        
        if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) {
            $auth = Zend_Auth::getInstance();

            $options = array(
                'userIdKey'   => 'userIdKey:*',
                'userDataKey' => 'users:*',
                'userDataIsArray' => true
            );
            $adapter = new Rediska_Zend_Auth_Adapter_Redis($options);

            // Set login and password
            $adapter->setIdentity($form->getElement('login')->getValue())
                    ->setCredential($form->getElement('password')->getValue());
                    
            // Authorization
            $result = $auth->authenticate($adapter);
            if ($result->isValid()) {
                $userData = $adapter->getResultUserData();

                $session = new Zend_Session_Namespace('Zend_Auth');
                
                $storage = $auth->getStorage();
                $storage->write($userData);
                
                $this->_redirect('/post/index/');
            } else {
                $form->getElement('login')->addError('Wrong login/password combination');
            }
        }
        
        $this->view->form = $form;
    }
Login