I”m trying to create a 2 dimensional array as a cookie in javascript. Is this possible? First of all, how do I create this array cookie? Second of all, how do I loop through this array cookie in order to retrieve data. Thanks alot!!!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You combine the use jQuery.cookie plugin and JSON and solve your problem.
When you want to store an array,You created an array in JS and use
JSON.stringifyto transform it into an string and stored with$.cookie('name', 'array_string')When you want to retrive the array inside the cookie, you use
$.cookie('name')to retrive the cookie value and useJSON.parseto retrive the array from the string.