0

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
}
random
  • 9,774
  • 10
  • 66
  • 83
dana
  • 5,168
  • 20
  • 75
  • 116

2 Answers2

1

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

Kemo
  • 6,942
  • 3
  • 32
  • 39
  • than the referrer is empty :) either your browser has disabled referrer header (web developer toolbar for firefox and similar plug-ins have the habbit to turn it off) or you're accessing the page directly (in which case there is no referrer) – Kemo Jun 20 '11 at 20:34
0
Request::$referer 

should contain the referer url.

Ikke
  • 99,403
  • 23
  • 97
  • 120