I set the cookie so
public function actionCountry(){ $name=Yii::$app->request->get("name","Russia"); $cookies = Yii::$app->response->cookies; // добавление новой куки в HTTP-ответ $cookies->add(new \yii\web\Cookie([ 'name' => 'country', 'value' => $name, ])); // $session=\Yii::$app->session; //$session->set('country',$name); //$session->remove('name'); return $this->render('country',[ 'name'=>$name, 'cookies'=>$cookies->getValue('country') // 'session'=>\Yii::$app->session->get('country') ]); } } I treat it like this
public function actionIndex() { $cookies= \Yii::$app->request->cookies; return $this->render('index',[ 'cookies'=>$cookies->getValue('country') //'session'=>\Yii::$app->session->get('country') ]); } I deduce so
<p> Страна <a href="<?= Yii::$app->urlManager->CreateUrl(['country/country','name'=>$cookies]) ?>"> <?=$cookies?></a></p> The cookie is not created well, and therefore is not displayed. From where I know that the web developer is not being created, it does not display what the problem is. I have already reached the point that I have already simply created a country cookie through the developer and I am trying to withdraw it through
var_dump(Yii::$app->request->cookies['country']); returns null
shorter than the standard cookie, it outputs via request but does not generate a response