Laravel Cookies

Laravel Cookies

Using Cookies in Laravel is super easy. Take a look at how we can use cookies in Laravel below:

1. To Set a cookie you can use the following code:

$ref = 'my cookie value';
return redirect('/')->withCookie('ref', $ref);

2. Then to get a cookie value you can do the following:

$cookie = $request->cookie('ref');

And it’s as easy as that. To learn more about laravel cookies you can visit the official documentation.

Additionally you can learn more about Laravel cookies by checking out this video by DevDojo:

Learn how to use laravel cookies