I'm having an issue with deleting cookies in Laravel 5.6. I've tried various different things based on this, this, this and this question, but none of them work;
1.
return response()
->redirectToRoute('home')
->withCookie(Cookie::forget('code'))
->withCookie(Cookie::forget('email'));
2.
Cookie::queue(Cookie::forget('code'));
Cookie::queue(Cookie::forget('email'));
return redirect('/');
3.
Cookie::queue('code', null, -1);
Cookie::queue('email', null, -1);
return redirect('/');
4.
return redirect('/')
->withCookie(cookie('code', '', -1))
->withCookie(cookie('email', '', -1));
5.
return response()
->redirectToRoute('home')
->withCookie(cookie('code', '', -1))
->withCookie(cookie('email', '', -1));
3, 4 and 5 don't even change the value of the cookie, the original value still remains in the cookies. I don't know what other methods I could try, so any help would be appreciated.
Cookies are generally added like this in Laravel:
return response()
->redirectToRoute($this->handleRedirect($result))
->cookie('code', $request->code, $this->duration, null, $this->domain)
->cookie('email', $request->email, $this->duration, null, $this->domain);
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class
middleware enabled on your route?$middlewareGroups
array, this means it's used on all web routes by default, right?php artisan route:list
web
middelware group is enabled on all routes, so that's not the problem.