Support the ongoing development of Laravel.io →
posted 10 years ago
Session
Last updated 2 years ago.
0

Hmm... well, I know unsetting a cookie is achieved with the following:

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

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

but to do multiple, you could do this:

public function unsetCookies(Array $cookieList)
{
  if(!empty($cookieList)) {
    foreach($cookieList as $cookie) {
        $this->headers->setCookie($cookie);
        return $this;
    }
   }else {
        return Redirect::back()->with('Error', 'No cookies have been given for hunting and destroying!');
   }
}
Last updated 2 years ago.
0

In case anyone wanders in and wants to know, the answer is to make an array of the cookies and then use the withCookies method, which accepts an array as the parameter.

$cookie[0] = Cookie::forget('key1');
$cookie[1] = Cookie::forget('key2');

return Response::make('thisResponse')->withCookies($cookie); 

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.