0

我有一个基于 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
}
4

2 回答 2

1

尝试:

$ref = Request::$referrer;

并且为了获取 ref 的路线,您可以使用Request::process_uri($referrer_uri, $injected_routes)Kohana 3.1,但不能在 3.0 中使用。

您可以在 3.0 中手动添加:https ://gist.github.com/1031396

注入的路由数组是可选的,如果您有一个严格的要测试的路由列表(以跳过与所有路由进行比较的开销)。

于 2011-06-17T13:03:17.130 回答
0
Request::$referer 

应包含引荐来源网址。

于 2011-06-17T13:04:27.647 回答