beforeFilter()

在控制器每个动作之前执行,可以方便地检查有效的会话,或者检查用户的权限。

    function beforeFilter() {
        parent::beforeFilter();
        if(empty($this->user)) {
            $this->redirect('/home');
        }
    }
原文地址:https://www.cnblogs.com/xiaobiaomei/p/8973452.html