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?
I have a predispatch hook in plugin for authorization. In it if (and only if) user needs to be logged I save the request URI to session and after logging in I redirect there. There is no overhead except when redirecting to login form. But that's a case where overhead is no problem. :)
I see this already has an answer, but i'd like to throw mine in too, just as a different way to skin the cat sort of deal, using static methods.
This doesn't run all the time, only on a need to basis.
That's the whole code, part of my blog post here (http://hewmc.blogspot.com/2010/08/simple-way-to-store-last-visited-url-in.html)
You can try using HTTP_REFERRER header like this:
This Zend framework plugin allows you to save current and last qualified url and filter out unwanted urls. feel free to use and comment:
Basically the same thing that Jesta is doing in his answer, but I added the following functions to my "MW_Form" class - which is a superclass of all my forms - easy enough to
$form->trackReferrer($this->getRequest());
from the controller with any form. The getReferrer() function takes a "default" argument (which if the user has REFERER headers disabled, or there is no referrer - your going to want a default place to redirect back to)The Decorator Used - gives you the added benifit of not using up any rows in the
<dl>
created by zend_form:Example Usage (from a controller):