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

Installing Laravel

April 14th, 2015

Animate CSS

April 25th, 2015

Laravel 5.2 Authentication

January 26th, 2016

What is Sequel Pro

April 19th, 2015

Vue JS Intro

November 3rd, 2015

MAMP Introduction

April 12th, 2015

Flexbox Intro

November 11th, 2015

+1 Sushi Points!

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