/** * 检查是否存在session * 是否开启检查cookie,即isRemenberme * session不存在则检查cookie * 都不存在设为anonymous匿名用户 * 存在则获取用户信息存在$this->user */ public function check() { // 检查 Session 和 Cookie if ($this->checkSession()) { $this->setIsAnonymous(false); } else { if ($this->checkCookie()) { $this->setIsAnonymous(false); } } // 非匿名用户获得设置 User 信息 if (!$this->isAnonymous) { // 用户信息 $user = $this->setUser($this->getSession()); // 认证通过,写入User信息 Request::setStorage('user', $user); } return $this; }