Creating and Retrieving Cookie in Laravel ?

Creating a new Cookie

$cookie = Cookie::make($name, $value, $minutes, $path, $domain,$secure, $httpOnly);

Creating A Cookie That Lasts Forever

$cookie = Cookie::forever('name', 'value');

To create a cookie that won’t expire for 60 minutes

$cookie = Cookie::make('name', 'value',60);

To create a cookie that will expire on browser close

$cookie = Cookie::make('name', 'value');

Retrieving Cookie

$val = Cookie::get('cookieName'); 
$name = Cookie::get('cookieName', 'defaultValue');

Delete Cookie

$cookie = Cookie::forget('cookieName');

 Make on view / All given used

return Response::make('test')->withCookie($cookie);


No comments

Note: only a member of this blog may post a comment.