Exemplo n.º 1
0
 /**
  * 用户登出
  * @return true删除成功,不为true是删除失败提示
  */
 public static function userLoginOut()
 {
     if (isset($_SESSION['userid']) && !empty($_SESSION['userid'])) {
         permission::usermodeDeleteByUserid($_SESSION['userid']);
         //删除状态临时表该用户的数据
     }
     $static_session = self::$static_session;
     foreach ($static_session as $s_key => $value) {
         if (isset($_SESSION[$s_key])) {
             $static_session[$s_key] = $_SESSION[$s_key];
             //session 保存
         }
     }
     $_SESSION = array();
     foreach ($static_session as $s_key => $value) {
         if (!empty($value)) {
             $_SESSION[$s_key] = $static_session[$s_key];
         }
     }
     $cookie = new CHttpCookie('userinfo', Yii::app()->params['web_server_host']);
     $cookie->expire = time() - 3600 * 24;
     //删除cookie
     Yii::app()->request->cookies['userinfo'] = $cookie;
 }