2010年10月22日星期五

Re: [fw-mvc] Referer

Well from user/edit i am redirected to user/login

In the login action i do:

$origin = $this->request()->getHeader('referer');
var_dump($origin);

And it gives me:

index/index

But i expect

user/edit

On Fri, Oct 22, 2010 at 4:58 PM, Matthew Weier O'Phinney
<matthew@zend.com>wrote:

> -- Jigal sanders <jigalroecha@gmail.com> wrote
> (on Friday, 22 October 2010, 04:48 PM +0200):
> > This is more of an architectual question which should lead for me to a
> > development decision.
> > I sometimes in my application have some links. But in order to see what's
> > behind the links you have to be logged in. So the user is redirected to a
> > login page.
> > But I want the user to be redirected to the original page after he has
> > logged in.
> >
> > What's the best way to implement this in a zf based site?
>
> Grab the referer from the request object:
>
> // In an action method of a controller
> $request = $this->getRequest();
> if (/* some op succeeded */) {
> $origin = $request->getHeader('referer');
> return $this->_redirect($origin);
> }
>
> That's really all there is to it.
>
> --
> Matthew Weier O'Phinney
> Project Lead | matthew@zend.com
> Zend Framework | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
>

--
Met vriendelijke groet,

Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489

没有评论: