You're watching:

Laravel Cookies

Sorry, this video is only available to Subscribers

Laravel Cookies
Favorite

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: https://laravel.com/docs/requests

Tags: laravel, cookies, laravel cookies

Episodes You May Like

Use Panda

April 26th, 2015

Flexbox Intro

November 11th, 2015

How to use Trello

May 31st, 2015

Vue JS Intro

November 3rd, 2015

Create a Sidebar Menu

May 16th, 2015

Glide PHP

January 29th, 2017

Intro To Pyro CMS

May 22nd, 2016

Better Touch Tool

May 31st, 2015

+1 Sushi Points!

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