Retrieving Input: Cookies

All cookies created by the Laravel framework are encrypted and signed with an authentication code, meaning they will be considered invalid if they have been changed by the client.

Retrieving Cookies From Requests

$value = $request->cookie('name');
$value = Cookie::get('name');

All cookies created by the Laravel framework are encrypted and signed with an authentication code, meaning they will be considered invalid if they have been changed by the client. To retrieve a cookie value from the request, use the cookie method on a Illuminate\Http\Request instance.

Alternatively, you may use the Cookie facade to access cookie values.

Attaching Cookies To Responses

Return response('Hello World')->cookie(
    'name', 'value', $minutes
);
Return response('Hello World')->cookie(
    'name', 'value', $minutes, $path, $domain, $secure, $httpOnly
);
Cookie::queue(Cookie::make('name', 'value', $minutes));

Cookie::queue('name', 'value', $minutes);
Return response($content)
                ->header('Content-Type', $type)
                ->cookie('name', 'value', $minutes);
->cookie($name, $value, $minutes, $path, $domain, $secure, $httpOnly)
Cookie::queue(Cookie::make('name', 'value', $minutes));

Cookie::queue('name', 'value', $minutes);
  • You may attach a cookie to an outgoing Illuminate\Http\Response instance using the cookie method. .
  • Alternatively, you can use the Cookie facade to "queue" cookies for attachment to the outgoing response from your application.
  • You may use the cookie method to generate a cookie and fluently attach it to the response instance.
  • Alternatively, you can use the Cookie facade to "queue" cookies for attachment to the outgoing response from your application.

Generating Cookie Instances

$cookie = cookie('name', 'value', $minutes);

return response('Hello World')->cookie($cookie);

If you would like to generate a Symfony\Component\HttpFoundation\Cookie instance that can be given to a response instance at a later time, you may use the global cookie helper.

Retrieving Input: Cookies — Structure map

Clickable & Draggable!

Retrieving Input: Cookies — Related pages: