Hi, I have a form that when the user is entering their details a few values are stored into an array. However when the form fails validation a error message is returned and the array value is lost. I want to save the array value after the form fails validation, and to achieve this I’m storing the value into a cookie.
var selectedDays = ["2015-11-25", "2015-11-26", "2015-11-27"];
var newStr = selectedDays;
var BookableArr = JSON.stringify(newStr);
Cookies.remove('bookableDates');
Cookies.set('bookableDates', BookableArr);
If the cookie is set then the value of the cookie is returned back into the forms array:
var selectedDays = [Cookies.get('bookableDates')];
But what is actually returned from the cookie is this
["2015-11-25","2015-11-26","2015-11-27"]
and on form validation error, selectedDays returns this:
["["2015-11-25","2015-11-26","2015-11-27"]"]
Making it one long array, opposed to multiple array values. Can anyone help me solve this problem?