jquery - JavaScript reading cookie not working -
i have been searching reading cookies lastly several hours , posted questions in site still no luck.
all need set cookie on 1 page , read cookie on other page. have tried escape , unescape no result.
here code on first page setting cookie
document.cookie = 'province=' +window.escape($(elem).text()) +'; expires=fri, 3 dec 2014 20:47:11 utc; path=/';
and here reading it
function re() { var = get_cookie("province"); alert(a); window.location = "lp.aspx?"+a; } function get_cookie(cookie_name) { var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)'); if (results) homecoming (window.unescape(results[1])); else homecoming null; }
i have tried answers on stackoverflow still looking solution.
again need set cookie on 1 page , read on other page.
try using following
var testcookievalue = $.cookie("testcookie"); // read $.cookie("testcookie", 1); // write
hope helps.
javascript jquery cookies
No comments:
Post a Comment