how does hash element make a secure login on zend framework?

Posted by ulduz114 on Stack Overflow See other posts from Stack Overflow or by ulduz114
Published on 2010-03-16T09:57:02Z Indexed on 2010/03/16 10:06 UTC
Read the original article Hit count: 451

hello all

i saw a example for login form same blow code

class Form_Login extends Zend_Form {
    //put your code here
    public function init($timeout=360){

        $this->addElement('hash', 'token', array(
             'timeout' => $timeout
        ));
        $this->setName('Login');
       $username = $this->createElement ( 'text', 'username' );
        $username->setLabel('user name:')
                ->setRequired();
                $this->addElement($username);
        $password=$this->createElement('password','password');
        $password->setLabel('password:');
        $password->setRequired();
        $this->addElement($password);
        $login=$this->createElement('submit','login');
        $login->setLabel('Login');
        $this->addElement($login);

        $this->setMethod('post');
        $this->setAction(Zend_Controller_Front::getInstance()->getBaseUrl().'/authentication/login');

    }
}

and in submitAction

a part code same below

if (!$form->isValid($request->getPost())) {
            if (count($form->getErrors('token')) > 0) {
                return $this->_forward('csrf-forbidden', 'error');
            }    
            $this->view->form = $form;
            return $this->render('login');
        }

now , my question, whats the reason for use of hash element? how this hash element make secure login?

anybody may help explain these?

thanks

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about hash