How to store array in jQuery cookie?

前端 未结 2 2090
一生所求
一生所求 2021-01-06 09:27

I\'m opening a new thread based on this how to store an array in jquery cookie?. I\'m using function from almog.ori :

var cookieList = function(cookieName) {         


        
2条回答
  •  日久生厌
    2021-01-06 10:25

    This line:

    $.cookie(cookieName, items);
    

    Should create the string from the array as well, like this:

    $.cookie(cookieName, items.join(','));
    

    This is so that when loading the array via cookie.split(/,/), it gets a string it expects (comma-delimited).

提交回复
热议问题