i wrote a cookie with javascript, but for some reason my code only reads the cookie when u refreash. when u close the browser and return to the site my code wont read the cookie, can some one help me???
heres my JS for reading the cookie
var your_cookie=document.cookie;
if(your_cookie.length>1)
{
var your_cookie = unescape(your_cookie);
break_cookie=your_cookie.split("/");
for(count=0;break_cookie[count].length>1;count++)
{
cookie_value=break_cookie[count].split("&");
shoppingcart(cookie_value[0],cookie_value[1]);
}
}
Cookies
Moderator: General Moderators
To answer your second question, just enter a numeric value instead of a string.
To answer your first question, yes - you do need to refresh the page before the cookie takes effect. That's the nature of cookies. Secondly, you've written what's called a "session-only" cookie, which means that the cookie will disappear once you close your browser. You need to add an expiration date to it so that it expires down the line instead of at the end of the session (which is closing your browser).
To answer your first question, yes - you do need to refresh the page before the cookie takes effect. That's the nature of cookies. Secondly, you've written what's called a "session-only" cookie, which means that the cookie will disappear once you close your browser. You need to add an expiration date to it so that it expires down the line instead of at the end of the session (which is closing your browser).