jQuery Cookie plug in behavior: is setting domain to “.com” if cookie is session cookie

半腔热情 提交于 2020-01-03 17:29:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!