销毁Laravel中所有无法使用的Cookie [英] Destroy all cookie in laravel not working
本文介绍了销毁Laravel中所有无法使用的Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用laravel 5.4框架,我想删除laravel中的记住我的cookie.我已经尝试过各种方法,例如 config/session.php
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 ?
推荐答案
要销毁cookie,请将其设置为$minutes
的负值(第三个参数).
To destroy a cookie, set it with a negative value for $minutes
(the third argument).
return redirect('/')->withCookie(cookie('cookie_name', '', -1));
来源: http://coursesweb.net/laravel/cookies
这篇关于销毁Laravel中所有无法使用的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文