问题描述
Folks,
我发现如果我设置的cookie是会话cookie,那么jQuery cookie插件将域设置为.com。
I've found that the jQuery cookie plugin is setting the domain to ".com" if the cookie I'm setting is a session cookie.
以下是代码:
jQuery.cookie("currentTab", selectedTab );
如果我使用IE的开发工具查看cookies,它显示域名为.com。
If I look at cookies with IE's Developer Tool, it shows the domain as ".com".
如果我这样设置:
jQuery.cookie("currentTab", selectedTab, { expires: 1} );
...然后它有www.sitename.com作为域。
... then it has "www.sitename.com" as the domain.
有没有一些诀窍我缺少,或者我发现了一个错误?
Is there some trick I'm missing, or have I found a bug?
推荐答案
好吧,我创建了这个,并在Chrome和Firefox中进行检查(网络开发者工具> Cookie>查看Cookie信息),他们拥有 fiddle.jshell。 net
。在IE8 IEDT告诉我他在我检查的所有页面上找不到cookie文件(?)。
Well, I've created this http://jsfiddle.net/jvDXZ/ and checked it in Chrome and Firefox (Web Developer Tool > Cookies > View Cookie Information), and they had fiddle.jshell.net
for both cookies. In IE8 IEDT is telling me he can't find the cookie file (?) on all the pages I've checked.
您可以检查您的IE如果cookie可通过其他 .com
域访问。如果不是(但您可以通过 www.sitename.com
)访问它,这显然是IEDT错误。
You can check in your IE if the cookie is accessible via other .com
domain. If it's not (but you can access it via your www.sitename.com
) - it's clearly IEDT bug.
这篇关于jQuery Cookie插件行为:正在将域设置为“.com”如果cookie是会话cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!