Cookie и laravel 5

Question:

I am trying to install a cookie in laravel 5 with the standard method i.e.

Cookie::make('room_1', $data, $minutes);

But unfortunately this does not work, I tried to add the queue facility to the queue

Cookie::queue('room_1', $data, $minutes);

It worked, but I still want to know why make does not work, I run it in the controller when the page is loaded

Answer:

Make only installs the cookie, and also needs to be passed to the client, for example:

$cookie = Cookie::make('room_1', $data, $minutes);
return $response()->withCookie(cookie($cookie));

The same can be done like this:

$cookie = Cookie::queue('room_1', $data, $minutes);
return $response();
Scroll to Top