Saving JSON object in cookies and read it when page loaded...
Hi, I have a json object as below..
var a1 = {"nope":["Retail Stores","Retail Development","Service station","Stations","branded wholesale/wholesaler","brand equity","Retail outlets","Forecourt","Corner store","Conveinence store","backcourt"]};
var a = JSON.stringify(a1);
and saving in cookies using
document.cookie = "MyTopicCookie="+k+";expires=Thu, 18 Dec 2017 12:00:00 UTC";
when I am reading cookies in next reloading of page.. using following code ( Thoudh in first reload it show previous cookies... just ignoring them)
var a = document.cookie.split(";");
alert(a);
alert(a[0]);
it thows the following error.
Exception thrown by application class 'javax.servlet.http.Cookie.:139'
java.lang.IllegalArgumentException: Cookie name "Retail Development" is a reserved token
at javax.servlet.http.Cookie.(Cookie.java:139)
at ...
SO my question is simple how to store the json object in cookies and read it back with all key values pairs.
Thanks in advance.