JavaScript code for cookie not working in Chrome

后端 未结 5 1307
谎友^
谎友^ 2021-01-01 16:59

The following code works fine in FF:

var date = new Date();
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
expires = \"; expires=\" + date.toGMTSt         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-01 17:29

    Try to replace this line:

    document.cookie = "c_odi" + "=" + $('#orderdetailid').val() + expires + "; path=/";
    

    with this one:

    document.cookie = "c_odi" + "=" + escape($('#orderdetailid').val()) + expires + "; path=/";
    

    You would have to use unescape when you try to read value, but you'll menage when time comes :)

提交回复
热议问题