Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to add a redirection URL to my login forms action (as a query) in login page, so after loging-in, one can visit the previous page he or she was surfing.

First I thought about using Zend Session and save the url of each page in a variable. but I read in the documentation that it has overhead. So, is there a better way to do so? or is there an other way to use zend session with no overhead?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
889 views
Welcome To Ask or Share your Answers For Others

1 Answer

First, you need to grab the original url for the redirection. You can do that by the Zend_Controller_Request class via:

$url = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();

or simply by:

$url = $_SERVER['REQUEST_URI'];

Then, the tricky part is to pass it through the user request. I recommend to use the library Zend_Session, despite using a POST parameter is also legitimate:

$session = new Zend_Session_Namespace('Your-Namespace');
$session->redirect = $_SERVER['REQUEST_URI'];

Please note that the address we kept includes the base path. To redirect the client in the controller class, disable the option 'prependBase' to lose the base path insertion:

$this->_redirect($url, array('prependBase' => false));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...