How can I delete or destroy cookie in Laravel 4?
I have created it using the next code:
return Response::make('', 302, array('Location' => $_SERVER['HTTP_REFERER']))->withCookie($cookie);
But in the end, I need to destroy this data.
How can I do this?
You have to use Cookie::forget like this:
$cookie = Cookie::forget('cookieKey');
return Response::make('foo')->withCookie($cookie);
remember you have to always return the cookie with the response, it's not like Session.
Im pretty sure its the forget()
method..
So in your case....when $cookie was made it was given a name, just unset it like so
Cookie::forget('yourCookie');
here is a list of frequently used with cookies .
u could check the detail on Laravel Api document . [2]http://laravel.com/api/class-Illuminate.Cookie.CookieJar.html
wish u good luck !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With