问题
Folks,
I've found that the jQuery cookie plugin is setting the domain to ".com" if the cookie I'm setting is a session cookie.
Here's the code:
jQuery.cookie("currentTab", selectedTab );
If I look at cookies with IE's Developer Tool, it shows the domain as ".com".
If I set this way:
jQuery.cookie("currentTab", selectedTab, { expires: 1} );
... then it has "www.sitename.com" as the domain.
Is there some trick I'm missing, or have I found a bug?
Thanks.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/7862608/jquery-cookie-plug-in-behavior-is-setting-domain-to-com-if-cookie-is-session