Destroy all cookie in laravel not working

2019-08-24 02:03发布

I use laravel 5.4 framework and I want to delete remember me cookie in laravel. I've tried various ways like Session::flush() $request->session()->flush(); $request->session()->regenerate(true); $this->driver->manage()->deleteAllCookies(); and 'expire_on_close' => true, in config/session.php

$remembercokkie = Auth::guard('administrator');
$cokkie = Cookie::forget($remembercokkie);
return redirect('/')->withCookie($cookie);

but nothing happen still the user log in. How do I fix this ?

1条回答
看我几分像从前
2楼-- · 2019-08-24 02:36

To destroy a cookie, set it with a negative value for $minutes (the third argument).

return redirect('/')->withCookie(cookie('cookie_name', '', -1));

Source: http://coursesweb.net/laravel/cookies

查看更多
登录 后发表回答