Cookie ::忘记无法正常使用Laravel 5.1 [英] Cookie::forget not working laravel 5.1

查看:70
本文介绍了Cookie ::忘记无法正常使用Laravel 5.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图让Laravel 5.1删除我的cookie,但是即使我通过重定向将其返回,它也不会删除.

I'm trying to get Laravel 5.1 to delete my cookie, however it will not delete even though i'm returning it with my redirect.

return redirect('/voucher')->withCookie(Cookie::forget($cookie));

我做错了什么吗?

推荐答案

也许我错了,但是调用Cookie::forget($cookie)时,您可能使用cookie对象代替了cookie名称.除非$cookie是包含cookie名称的字符串,否则应尝试执行以下操作:

Maybe I am wrong, but you are probably using cookie object in place of cookie name when calling Cookie::forget($cookie). Unless $cookie is a string containing cookie name, you should try something like this:

return redirect('/voucher')->withCookie(Cookie::forget('cookie_name'));

这篇关于Cookie ::忘记无法正常使用Laravel 5.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆