问题描述
有人知道有没有办法忘记所有的cookies(好吧,我的网络应用程序)在Laravel?我知道我可以通过 Cookie :: forget('mycookie')
摆脱一个,但如果我有一打左右,我想忘记他们?
Does anyone know if there's a way to forget all cookies (well, all for my web app) in Laravel? I know that I can get rid of one by doing Cookie::forget('mycookie')
but what if I have a dozen or so, and I want to forget them all?
是否有一个简单的单行命令,例如 Cookie :: forgetAll()
Is there a simple one-line command like Cookie::forgetAll()
or something? Or do I just need to loop through all my cookies and forget them one by one?
谢谢!
PS - 我使用的是Laravel 4.1.28,但会乐意更新到最新版本,如果它会有所不同。
PS - I'm using Laravel 4.1.28 but would happily update to the latest version if it will make any difference.
推荐答案
查看Laravel源代码(),似乎没有一次删除所有的cookie的功能,所以你只有选择的确会是循环所有Cookie,并逐个删除它们。
Looking at the Laravel source code (https://github.com/laravel/framework/blob/ef0864242e6e6f19a78f941b0710c844016ddf6e/src/Illuminate/Cookie/CookieJar.php), there doesn't seem to be a function to delete all the cookies at once, so you only option would indeed be to loop over all the cookies and delete them one by one.
这篇关于如何忘记laravel中的所有cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!