jquery cookie,cookie保存在哪里?
也许这是一个基本问题。但我仍然不确定jquery cookie
,将cookie保存在哪里?
像这样:http://code.google.com/p/cookies/wiki/Documentation
cookie 保存在服务器部分还是自定义浏览器部分?
我想保存在自定义浏览器部分。 jquery cookie
只是一个工具,它应该像php cookie/session
一样,保存每个cookie取决于不同的URL
。
但是当我看到它需要设置 domain
和 path
时。我很困惑,如果依赖于不同的URL
,为什么不使用domain
+ window.location.hash
? path
的用途是什么?
Maybe this is a basic question. but I still not sure jquery cookie
, save cookies in where?
like this one: http://code.google.com/p/cookies/wiki/Documentation
the cookies save in server part or in custom browser part?
I guess save in custom browser part. jquery cookie
just is a tool, it should be like php cookie/session
, save each cookie depends on different URL
.
But when I see it need set domain
and path
. I am puzzed, if it depends on different URL
, why not use domain
+ window.location.hash
? the path
for what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“JQuery cookie”是一个利用
document.cookie
的简单工具。这个基本的 JavaScript 功能将 cookie 存储在用户的浏览器中。可以使用一些属性来定义 cookie:
max-age
- 过期日期(以秒为单位)(Jquery 实现:{expires: __}
以天为单位)domain
- 默认情况下,cookie 保存在当前域中。但是,可以将域更改为从当前子域到顶级域的任何域(sub.sub2.top.nl
->sub2.top.nl
-> ;top.nl
,但不是another.top.nl
)。path
- 默认情况下,cookie 应用于/
。可以更改此默认值,以便仅匹配特定目录。secure
- 可以通过在 JQuery 中传递secure: true
来添加此标志。设置此选项后,cookie 仅针对 HTTPS 协议。"JQuery cookie" is a simple tool which makes use of
document.cookie
. This basic JavaScript feature stores cookies at the user's browser.A cookie can be defined with some properties:
max-age
- Expiration date in seconds (Jquery implementation:{expires: __}
in days)domain
- By default, a cookie is saved at the current domain. It's however possible to change the domain to any domain from the current subdomain to the top domain (sub.sub2.top.nl
->sub2.top.nl
->top.nl
, but notanother.top.nl
).path
- By default, the cookie is applied to/
. It's possible to change this default, so that only a specific directory is matched.secure
- This flag can be added through passingsecure: true
in JQuery. When this option is set, cookies are targeted at the HTTPS protocol only.