I an redirection (in some cases) from a controller to the error controller, action ‘not-logged-in’ using the redirector helper. My problem is the following: I want to pass an argument in the $_POST array (an URL from where the redirection happened) so the user will be able to return to that page after performing a login.
How can i place data in the $_POST array while using redirect helper?
Thank you ahead.
When you use the redirector with an internal redirect (ie.
goToRoute) the paramters are passed along with it. Thus if you add your refferrer to the the request before you actually redirect:then that variable will be passed along with the request upon redirect. So then you would need to check for/grab that variable from the request in the action youve redirected to and then set it as a hidden field in the form. Then when your form posts to your login action you can check again for a
refvariable and on successful login redirect to that location.Now if i were you i would not actually use the referral as the url but a serialized or json encoded array of the previous request’s parameters. that way you can use
goToRoutein this second instance as well.Ofcourse if the redirection came form some sort of post action that contained sensitive data you wouldnt want to do this. In that case you would want to use the session as has been previously suggested.
Above all the best advice i can give is to look at the code of
Zend_Controller_Router_RewriteandZend_Controller_Action_Helper_Redirector.