Jquery Cookie plugin - multiple values?

后端 未结 4 520
长情又很酷
长情又很酷 2020-12-18 00:18

I am using popular jquery Cookie plugin https://github.com/carhartl/jquery-cookie Wonder how to set and read a cookie with multiple values? Or maybe it\'s possible to add/re

4条回答
  •  清酒与你
    2020-12-18 00:58

    When I was using the

    var obj = { a: 'test', b: 'best' };
    $.cookie("MyCookie", $.param(obj), { expires: 10 });
    

    I was getting this value in the cookie

    a%3Dtest%26b%3Dbest

    So to get something like

    a=test&b=best

    you need to add this line before $.cookie()

    $.cookie.raw = true;
    

提交回复
热议问题