我有一个基于Kohana的网站,我想在功能中验证用户来自哪里。因此,如果他来自特定路线,我必须将他重定向到某个地方。
有没有办法在Kohana 3.0中验证用户来自哪条路线(或者只是来自哪里)?
代码示例:
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
}
答案 0 :(得分:1)
尝试:
$ref = Request::$referrer;
并且为获取ref的路由,您可以将Request::process_uri($referrer_uri, $injected_routes)
与Kohana 3.1一起使用,但不能在3.0中使用。
您可以在3.0中手动添加:https://gist.github.com/1031396
如果您有要测试的路由的严格列表(以跳过与所有路由进行比较的开销),则
注入路由数组是可选的。
答案 1 :(得分:0)
Request::$referer
应包含referer网址。