$cookies = Yii::$app->request->cookies;
if (!$cookies->has($cookieName)) {
Yii::$app->response->cookies->add(new \yii\web\Cookie([
'name' => $cookieName,
'value' => 'test',
'expire' => time() + 3600 * 24 * 365
]));
} else {
$value = Yii::$app->response->cookies->get($cookieName);
}
$cookies = Yii::$app->request->cookies;
if (!$cookies->has($cookieName)) {
Yii::$app->response->cookies->add(new \yii\web\Cookie([
'name' => $cookieName,
'value' => 'test',
'expire' => time() + 3600 * 24 * 365
]));
} else {
$value = $cookies->get($cookieName);
}
Yii::$app->response->cookies
Yii::$app->request->cookies