pass variable from one Action to Another Action In ZF

769 views Asked by At

i have a situation like this

public function loginAction(){
         //my other code
         if(!empty($errorMessage)){
          $this->view->assign('error',$errorMessage);
           } 
 }

public function authAction(){
    //my other code
    if($result->isValid()){
     $this->_redirect('/currentcontroller/controlpannel');}
     else{
     $errorMessage = "Wrong username or password provided. Please try again.";
         $this->_redirect('/currentcontroller/login');
       }

i want to pass $errorMessage to login action in else how to pass it and than how to retrive it there ??

1

There are 1 answers

0
Tim Fountain On BEST ANSWER

Take a look at the flash messenger action helper: http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.flashmessenger

It allows you to set messages (which are stored in the session), which you can access on the next request.