I’m not sure whether this problem is discussed before but I want o store a javascript object in cookie through javascript.
Basically my problem is I’ve a html form with few input fields. I want to take input from the fields and store the same values in a javascript object. This javascript object is only accessible until I’m in this page. But once I go to another page, my javascript object becomes null/undefined. So I thought I can store the javascript object somewhere from where I can get back the values I entered from the input fields. But I don’t know how I should be able to do this.
Any help will be appreciated.
Thanks,
Rupam
Cookie is the way to go.
You can do something like :
Add the plugin: https://github.com/carhartl/jquery-cookie
Setting a cookie:
$.cookie(“CookieName”,”CookieValue”);
Clearing the cookie:
$.removeCookie(“CookieName”);
Accessing the value in the cookie:
var temp = $.cookie(“CookieName”);