What I have found as a simple method to accomplish this is just to have a hidden field in your login form.
Now, im not sure if your login form is a generic HTML element or is actually an instance of Zend_Form
, but if its an instance of Zend_Form
, you could simple add the following:
$this->addElement('hidden', 'return', array(
'value' => Zend_Controller_Front::getInstance()->getRequest()->getRequestUri(),
));
Then in my authentication script, like the comment above, I have a simple redirect that uses the value passed in to return them to the same page.
$this->_redirect($this->_request->getPost('return'));
Obviously in these two examples, they are just written to compact the code and probably do not represent the best way to accomplish it. The two methods using the getRequest()
in my code are actually not embedded in the redirect
or the addElement
, but for example purposes I just slid them in there.
The answer above will obviously work as well, unless you have some massive page redirection going on. The main reason I am running mine this way right now is because not all of my forms are running in Zend_Form
and its also nice being able to change the value of the hidden return
input text box for testing purposes.