开发者

Redirect after checking referrering route in Kohana

I have a Kohana-based website and I want to verify, in a function, where a user comes from. So if he comes from a specific route, I have to redirect him somewhere.

Is there a way to verify what is the route a user comes from (or simply where he comes from) in Kohana 3.0?

Code example:

public func开发者_JAVA百科tion action_after_register(){

    if ($this->authlite->logged_in())
    {
        $this->redirect('Home');
    }
    // verify if he comes from a specific route and redirect him accordingly
}


Try with:

$ref = Request::$referrer;

and for getting the route for the ref, you can use Request::process_uri($referrer_uri, $injected_routes) with Kohana 3.1 but not in 3.0.

You can add it manually in 3.0: https://gist.github.com/1031396

Injected routes array is optional, if you have a strict list of routes you want to test against (to skip the overhead of comparing to all routes).


Request::$referer 

should contain the referer url.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜