Answer the question
In order to leave comments, you need to log in
How to send cookie to browser using yii2?
Hello!
The question is the following. There is a method:
public function actionTest() {
$cookie = new \yii\web\Cookie([
'name' => 'test',
'value' => 'test cookie value',
//'expire' => time() + 3600 * 24 * 1000,
]);
Yii::$app->response->cookies->add($cookie);
}
public function actionTest() {
$cookie = new \yii\web\Cookie([
'name' => 'monster',
'value' => 'test cookie value',
//'expire' => time() + 3600 * 24 * 1000,
]);
Yii::$app->response->cookies->add($cookie);
return $this->render('index');
}
Answer the question
In order to leave comments, you need to log in
public function actionTest() {
$cookie = new \yii\web\Cookie([
'name' => 'monster',
'value' => 'test cookie value',
//'expire' => time() + 3600 * 24 * 1000,
]);
Yii::$app->response->cookies->add($cookie);
return $this->render('index');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question