千巷猫影
$cookies = Yii::$app->response->cookies;// add a new cookie to the response to be sent$cookies->add(new \yii\web\Cookie(['name' => 'username','value' => 'yiiuser',]));获取 Cookies$cookies = Yii::$app->request->cookies;// get the cookie value$username = $cookies->getValue('username');//return default value if the cookie is not available$username = $cookies->getValue('username', 'default');// Check the availability of the cookieif ($cookies->has('username'))echo $cookies->getValue('username');删除 Cookies$cookies = Yii::$app->response->cookies;$cookies->remove('username');unset($cookies['username']);