cookie设置代码如下<script type="text/javascript">
<!--
function Cookie()
{

 this.SetCookie = function(name, value, expires) {
document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires.toGMTString() : "" );
 };

 this.GetCookie = function( name ){
var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
if (arr != null) return unescape(arr[2]); return null;
 };
} var cookie = new Cookie();
cookie.SetCookie("Csdn", 2009);
alert(cookie.GetCookie("Csdn"));
//-->
</script>在IE,FF,Opera下测试有效(2009),但在Chrome浏览器下为NULL。了解的看下。

解决方案 »

  1.   

    Chrome doesn't support cookies for local files unless you start it with the --enable-file-cookies flag. You can read a discussion about it at http://code.google.com/p/chromium/issues/detail?id=535.
      

  2.   

    谢谢natineprince should only run Chrome with a special command-line
      

  3.   

    我已经在Chrome里面设置了允许设置本地数据了,为什么还是不行呢?