Tuesday, March 7, 2017

Working with Laravel 5.3 cookies

I'm trying to create a cookie in my application registration method, using laravel class Cookie, but when I try to retrieve it in another controller method I get a null value.

Here is how I created it:

$cookie = Cookie::make('user_data', $user_data, 43800);

In that method, if I print it, it gives me the correct value, but after registration, if the user goes back to the registration URL, I need to check if the cookie exists, but it is giving me null when I print it.

dd(Cookie::get('user_data'));

What am I doing wrong?



via Aarón Gutiérrez

Advertisement