servlet 设置 cookie 安全吗? [英] servlet set cookie secure?
本文介绍了servlet 设置 cookie 安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
javax.servlet.http.Cookie implements java.lang.Cloneable
在 Cookie 方法中,有一个方法调用 "setSecure" ,它有什么用?如果我设置了安全(真),我需要在我的客户端(javascript)端做什么来读取 cookie?设置/不设置 setSecure 有何不同?
In Cookie method, there is a method call "setSecure" , what does it use for? if i setSecure(true), is there anything i need to do on my client(javascript) side to read the cookie? what is different set/without setSecure?
推荐答案
setSecure(true)
是告诉浏览器只有在使用安全"协议时才应将 cookie 发送回服务器,像https
.您的 JavaScript 代码不必做任何不同的事情.
All that setSecure(true)
does is tell the browser that the cookie should only be sent back to the server if using a "secure" protocol, like https
. Your JavaScript code doesn't have to do anything different.
这篇关于servlet 设置 cookie 安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文