Question

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 function action_after_register(){

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

Solution

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).

OTHER TIPS

Request::$referer 

should contain the referer url.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top