When I logined and then logout , in my function I cannot read my cookies like this:
public function cookiesLogin(){ $salt = 'GYHZMFSWP'; $permanent = $this->cookies->get('permanent')->getValue(); $identifier = $this->cookies->get('identifier')->getValue(); var_dump($permanent); var_dump($identifier);echo "identifier:".$identifier; //查找数据库 $remember=RememberTokens::findFirstByIdentifier($identifier); //比对是否是cookie对应的 if($permanent == $remember->permanent){ echo "permanent true"; echo $identifier; echo md5($salt . md5($remember->getUser()->name .$salt)); if($identifier == md5($salt . md5($remember->getUser()->name .$salt))){ echo "identifier true"; if((time()-(86400*8))<$remember->createdAt){echo "time true"; $user= Users::findFirstById($remember->userid );echo "user true"; $this->regSessionAuth( $user );echo "regSessionAuth true"; //重新产生cookie $this->rememberMe( $user );echo "rememberMe true"; return true; } } } $this->cookies->get('permanent')->delete(); $this->cookies->get('identifier')->delete(); return false; }