📜  yii2 获取 cookie - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:28.800000             🧑  作者: Mango

代码示例2
// get the cookie collection (yii\web\CookieCollection) from the "response" component
$cookies = Yii::$app->response->cookies;

// add a new cookie to the response to be sent
$cookies->add(new \yii\web\Cookie([
    'name' => 'language',
    'value' => 'zh-CN',
]));

// remove a cookie
$cookies->remove('language');
// equivalent to the following
unset($cookies['language']);