public function indexAction() { if(Zend_Auth::getInstance()->hasIdentity()) { $this->_redirect('profile/index/edit'); } $form = new App_Form_Login(); if($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if($form->isValid($formData)) { $auth = Zend_Auth::getInstance(); $authAdabter = new Zend_Auth_Adapter_DbTable( Zend_Registry::get('db'), 'portal_user', 'user_name', 'user_password', 'MD5(?) and active = 1' ); $authAdabter->setIdentity($form->getValue('user_name')) ->setCredential($form->getValue('user_password')); $result = $auth->authenticate($authAdabter); if($result->isValid()) { $userObj = $authAdabter->getResultRowObject('null', 'user_password'); $auth->getStorage()->write($userObj); $this->_redirect('profile/index/edit'); } else { $errorMessage = 'Nieprawidlowe login lub haslo!'; } } } $this->view->error = $errorMessage; $this->view->form = $form; }
i tak odczytuje
$user = Zend_Auth::getInstance()->getIdentity()->user_id;