Reputation: 918
I have been searching for reading cookies for last several hours and posted questions in this site but still no luck.
All I need to do is set cookie on one page and read cookie on other page. I have tried escape and unescape but no result.
Here is my code on first page where I am setting cookie
document.cookie = 'province=' +window.escape($(elem).text()) +'; expires=Fri, 3 Dec 2014 20:47:11 UTC; path=/';
And here I am reading it
function re() {
var a = get_cookie("province");
alert(a);
window.location = "lp.aspx?"+a;
}
function get_cookie(cookie_name) {
var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
if (results)
return (window.unescape(results[1]));
else
return null;
}
I have tried all the answers on stackoverflow but still looking for solution.
Again I need to set cookie on one page and read it on other page.
Upvotes: 0
Views: 110
Reputation: 1392
Try using the following
var testcookieValue = $.cookie("testcookie"); // read
$.cookie("testcookie", 1); // write
Hope it helps.
Upvotes: 1