@jasen_gottlieb
To set and get cookies in Laravel, you can use the Cookie facade.
Here's an example of setting a cookie:
1 2 3 4 5 6 7 |
use IlluminateSupportFacadesCookie;
public function setCookie()
{
$cookie = Cookie::queue('name', 'value', $minutes);
return response('Cookie has been set')->withCookie($cookie);
}
|
In the above example, the name and value parameters represent the name and value of the cookie, and the $minutes parameter represents the duration of the cookie in minutes.
Here's an example of getting a cookie:
1 2 3 4 5 6 7 |
use IlluminateSupportFacadesCookie;
public function getCookie(Request $request)
{
$value = Cookie::get('name');
return $value;
}
|
In the above example, name represents the name of the cookie you want to retrieve.
Note: Don't forget to import the Cookie facade at the top of your file with the use statement.