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