Need help setting cookie path

Giganews Newsgroups
Subject: Need help setting cookie path
Posted by:  J. Bruce (virtualbl…@hotmail.com)
Date: Fri, 25 Jul 2003

Does anyone know how to set the path in the script below so that the cookie
is accessible to all directories?

TIA

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function newCookie(){
xName = document.form.one.value;
SetCookie ('xName', xName, exp);
xPrice = document.form.two.value;
SetCookie ('xPrice', xPrice, exp);
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
//  End -->
</SCRIPT>

Replies