我使用jQuery Cookie插件(download、demo和source code with comments)来设置和读取Cookie.我正在开发local machine的页面.
The following code will successfully set a cookie in FireFox 3, IE 7, and Safari (PC). But if the browser is Google Chrome AND the page is a local file, it does not work.
$.cookie("nameofcookie", cookievalue, {path: "/", expires: 30});
What I know:
- The plugin's demo works with Chrome.
- 如果我把我的代码放在网络服务器上(地址以http:///开头),它可以与Chrome一起工作.
所以cookies 只会失败for Google Chrome on local files次.
Possible causes:
- Google Chrome doesn't accept cookies from web pages on the hard drive (paths like file:///C:/websites/foo.html)
- Something in the plugin implentation causes Chrome to reject such cookies
有人能证实这一点并找出根本原因吗?