Frage

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
}
War es hilfreich?

Lösung

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

Andere Tipps

Request::$referer 

should contain the referer url.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top