0

I am currently using this JQuery cookie plugin https://github.com/js-cookie/js-cookie and it is working for just single cookie value but i want it to work for multiple dynamic values stored in as an array.

For example, i have a list of the products in a page and i am showing "save products" link on each products. I want, clicking on the save button to store an id of the products in same cookies so i can retrieve all the values and display in a separate page.

I will appreciate if you can just show me how to store values in a cookies as an array i will do the rest.

HTML:

<ul>
 <li id="product1">product 1 <a>Save Products</a></li>
 <li id="product2">product 2 <a>Save Products</a></li>
</ul>

JQUERY:

$('ul li a').each(function(){
 $('this').click(function(){
  Cookies.set('SavedProducts', { foo: 'bar' });
 });
});
orbnexus
  • 737
  • 1
  • 9
  • 38

1 Answers1

0

In my opinion, since orignal cookie only supports TEXT based saving, You should serialize the arrays/tuple before storing as cookie.

Please Refer the following link. how to store an array in jquery cookie?

Good Luck

Community
  • 1
  • 1
Kwang-Chun Kang
  • 351
  • 3
  • 12