无法读取或写入cookie或其他内容

时间:2014-05-09 21:31:36

标签: javascript cookies

我似乎无法正确设置cookie,或者我可能没有正确阅读它。

alert(m)= name=Player; pl={"inf":0,"pop":0,"empty":{}}; expires=Thu, 01 Jan 2015 00:00:01 GMT; path=/;

提醒(cs)= name=Player ?

不确定为什么cs不等于m

save: function(){
    //erase cookies
    document.cookie = 'name=Player; expires=Thu, 01 Jan 1970 00:00:01 GMT;';


    var pl = "pl=" + JSON.stringify( this.player.getAsJSON() );
    var ex = "expires=Thu, 01 Jan 2015 00:00:01 GMT";
    var path = "path=/";

    var m = "name=Player; " + pl + "; " + ex + "; " + path + "; ";
    alert(m);

    //create new cookie
    document.cookie = m;
},

getSave: function(){
    var cs = document.cookie; 
    alert( cs );
    /*var parts = cs.split("; ");*/

}

0 个答案:

没有答案