Connecting Tech Pros Worldwide Help | Site Map

Need help setting cookie path

J. Bruce
Guest
 
Posts: n/a
#1: Jul 20 '05
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>


Klaus Johannes Rusch
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Need help setting cookie path


"J. Bruce" wrote:
[color=blue]
> Does anyone know how to set the path in the script below so that the cookie
> is accessible to all directories?
>
> 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;[/color]

SetCookie(name, value, expires, '/');

--
Klaus Johannes Rusch
KlausRusch@atmedia.net
http://www.atmedia.net/KlausRusch/


Closed Thread