Php Kohana 3.2身份验证模块和致命错误

Php Kohana 3.2身份验证模块和致命错误,php,web-applications,kohana-3.2,Php,Web Applications,Kohana 3.2,这不是一个严肃的问题。 但是我在Kohana3.2中发现了一些东西(我不明白) 所以,我已经用Auth模块实现了授权 并始终使用此代码检查授权 //in controller if(Auth::instance()->get_user() == null)// not login { $this->request->redirect("authen/login"); //navigate to login page } 它工作得很好

这不是一个严肃的问题。 但是我在Kohana3.2中发现了一些东西(我不明白)

所以,我已经用Auth模块实现了授权 并始终使用此代码检查授权

//in controller
    if(Auth::instance()->get_user() == null)// not login
    {
         $this->request->redirect("authen/login"); //navigate to login page
    }
它工作得很好

然后,我尝试将此代码放在视图文件中。(视图文件中的任意位置)

这看起来像是正常情况,因为$dummy没有定义

然后我刷新它或导航到其他页面

Auth::instance()->get_user() == null // it become true, after fatal error happen !! and redirect me to login page
我的问题是 -为什么“Auth::instance()->get_user()”在发生致命错误后返回null


有人共享此信息吗?

您应该检查用户是否通过以下方式登录:

if ( ! Auth::instance()->logged_in())
    $this->request->redirect("authen/login");
Auth::instance()->get_user() == null // it become true, after fatal error happen !! and redirect me to login page
if ( ! Auth::instance()->logged_in())
    $this->request->redirect("authen/login");