RealBeginner
07-15-2002, 12:27 PM
Hi All
I have the following js to set a cookie
"function SetCookie(name, value, expires, days)
{
var cookies = document.cookie; // cookies for site
var ix1; // index
var n1 = name; // main cookie name
var n2 = ""; // crumb name
var out; // returned value
var p2 = value; // new value
var p3 = expires; // param work area
var p4 = days;
var msd = 1000 * 60 * 60 * 24; // milisecs per day
if (!p3) { // no expiration
if (!p4) { p4 = 1; } // no days: use 1
p3 = new Date();
p3.setTime(p3.getTime() + msd * days);
}
ix1 = n1.indexOf(";"); // cookie/crumb break
if (ix1 != -1) {
n2 = n1.substring(ix1 + 1); // crumb name
n1 = n1.substring(0, ix1); // main cookie name
}
out = GetCookieCrumb(cookies, n1);
if (n2) {
if (out) { out = GetCookieCrumb(out, n2); }
else { rest = ""; }
if (rest) { p2 = rest + ";" + n2 + "=" + p2; }
else { p2 = n2 + "=" + p2; }
}
document.cookie=n1+"="+escape(p2)+"; expires="+p3.toGMTString();
}"
I have a form with a button and onClick I set the cookie:
function set() { SetCookie("name", document.order.FirstName.value, "",365);}.
The cookie is set from a page within a downloads folder which sits on my www.cortell.co.za domain.
How can I set the cookie to read any page within my domain.
Please help I have looked the web silly and cannot understand how to do it.
Thanks
RealBeginner
I have the following js to set a cookie
"function SetCookie(name, value, expires, days)
{
var cookies = document.cookie; // cookies for site
var ix1; // index
var n1 = name; // main cookie name
var n2 = ""; // crumb name
var out; // returned value
var p2 = value; // new value
var p3 = expires; // param work area
var p4 = days;
var msd = 1000 * 60 * 60 * 24; // milisecs per day
if (!p3) { // no expiration
if (!p4) { p4 = 1; } // no days: use 1
p3 = new Date();
p3.setTime(p3.getTime() + msd * days);
}
ix1 = n1.indexOf(";"); // cookie/crumb break
if (ix1 != -1) {
n2 = n1.substring(ix1 + 1); // crumb name
n1 = n1.substring(0, ix1); // main cookie name
}
out = GetCookieCrumb(cookies, n1);
if (n2) {
if (out) { out = GetCookieCrumb(out, n2); }
else { rest = ""; }
if (rest) { p2 = rest + ";" + n2 + "=" + p2; }
else { p2 = n2 + "=" + p2; }
}
document.cookie=n1+"="+escape(p2)+"; expires="+p3.toGMTString();
}"
I have a form with a button and onClick I set the cookie:
function set() { SetCookie("name", document.order.FirstName.value, "",365);}.
The cookie is set from a page within a downloads folder which sits on my www.cortell.co.za domain.
How can I set the cookie to read any page within my domain.
Please help I have looked the web silly and cannot understand how to do it.
Thanks
RealBeginner