You're watching:

Laravel Cookies

Sorry, this video is only available to Subscribers

Laravel Cookies

In this video we'll be teaching you just how easy it is to use cookies in your Laravel project.

In order to set a cookie you would need to redirect the user and set a cookie by using the following code:

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

If you wanted to set a cookie that lasted forever you would use the following code:

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

Then in order to get the value of a cookie we would use the following code:

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

To learn more about using Laravel cookies you can checkout the laravel official documentation at:

Tags: laravel, cookies, laravel cookies

Episodes You May Like

Animate CSS

April 25th, 2015

Laravel Multiple File Upload

December 27th, 2015

okayNav jQuery Plugin

March 18th, 2016

Laravel Socialite

October 25th, 2016

CSS Hamburgers

March 23rd, 2016

Better Touch Tool

May 31st, 2015

+1 Sushi Points!

Nice Job! You've just earned 1 Sushi Points for accomplishing