[Javascript] HELP WITH COOKIES!!!

Podlesny, Michael MPodlesny at acsisinc.com
Tue Nov 19 13:34:33 CST 2002


Can anyone help me out with cookies written in Javascript.  When I set my
cookies they are only available to the page that I set them on.  Does anyone
have any ideas on how to fix this?  Here is the code below:

function set_cookie(cookie_name, value)
{
	document.cookie = cookie_name+"="+value;
}

function get_cookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}



More information about the Javascript mailing list