Sunday, May 21, 2017

Laravel 5.4 Cookie Value

I am trying to get the value of a cookie.

1 When I use Laravel's request cookie helper:

$request->cookie('CookieName');

Laravel returns the cookie's name instead of its value.

2 When I dd() the the cookie() function:

dd(cookie('CookieName'));

I get:

#name: "CookieName"
#value: null
#domain: null
#expire: 0
#path: "/"
#secure: false
#httpOnly: true
-raw: false
-sameSite: null

3 When I use PHP's build in $_COOKIE function:

$_COOKIE['CookieName'];

I actually get the cookie's value.


Is there a way I can get Lavavel to return the cookie's value?



via Joshua Wieczorek

Advertisement