/ Published in: PHP
redirecting back to where the user came from is a very common functionality in login forms.
technical implementation:
- have a hidden field (
returnUrl) - populated by current url (in Zend Framework, i get this using the request's
getRequestUri()function) - in the
AuthController, if thereturnUrlfield is set, i will redirect the user to that page using theRedirectorhelper.
Expand |
Embed | Plain Text
// Login form class $controllerFront = Zend_Controller_Front::getInstance(); $returnUrl = $controllerFront->getRequest()->getRequestUri(); 'value' => $returnUrl )); // AuthController // inside loginAction() - after authentication is successful $returnUrl = $form->getElement('returnUrl')->getValue(); $this->_helper->getHelper('Redirector')->setGotoUrl($returnUrl); }
You need to login to post a comment.
