在cookie中将httponly属性设置为false [英] Setting the httponly property to false in a cookie
本文介绍了在cookie中将httponly属性设置为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用Laravel使用Cookie::Make
(或其他方式)制作cookie并将httponly属性设置为false?
How would i using Laravel make a cookie using Cookie::Make
(Or something else) and set the httponly property to false?
我想这样做,因为cookie包含我的JS必须能够读取的密钥.
I would want to do this as the cookie contains a key which my JS must be able to read.
推荐答案
Laravel为此提供了一个选项,但文档未显示.最好的方法是浏览源代码.如果您查看CookieJar.php文件此处您将看到httpOnly选项.
Laravel provides an option for this, but the docs don't show it. The best way is to look through the source. If you take a look at the CookieJar.php file here you'll see the httpOnly option.
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
因此只需执行以下操作即可:
so simply do something like:
Cookie::make('MyCookie', 'MyValue', 60, null, null, false, false);
这篇关于在cookie中将httponly属性设置为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文