Why not create cookies Yii2?

Good day. The crux of the matter:

The person chooses the currency on the website, after which it is sent to a controller, where the cook

 $(".sm-selector").on("change", function(){
 var val = $(this).val();
 url: "/currency-helper/set-currency"
 data: {id: val},
 type: "get"
 alert("currency setting" + data);
 alert("something went wrong");

Not so important as is sent to the controller there is some number from 1 to 5.

Here is how Yii 2 treats:

public function actionSetCurrency($id) {
 $cookiesOut = Yii::$app->response->cookies;
 $cookiesOut->add(new \yii\web\Cookie([
 'name' => 'currency',
 'value' => $id,
 'expire' => time() + 84000 * 365,
 'path' => '/',
 'domain' => '.example.com',
 return $id;

April 3rd 20 at 18:27
0 answer

Find more questions by tags Yii