Click to See Complete Forum and Search --> : document.cookie property returns null in NS7.1 XP version


aguntook
11-10-2003, 01:39 PM
The property document.cookie returns null even when the cookie manager shows the cookie has been
set and valid. The same code works in NS7.1 NT Version but errors in NS7.1 XP Version. The JS code extract is:

function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
var path = "/";
var domain = ".mydomain.com";
var secure = "false";
if (nDays==null || nDays==0) nDays=2;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName + "=" + escape (cookieValue) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}
function GetCookie (name) {
var arg = name + "=";
var test ;
var allcookies=document.cookie+';' ;
var offset ;
var start ;
var end ;
alert('Debugging 1:allcookies value='+allcookies) ;
allcookies.concat(';') ;
offset = allcookies.indexOf(arg) ;
start = arg.length ;
alert('Stage 1-Length is:'+start) ;
if (offset != -1) {
start = offset + arg.length ;
end = allcookies.indexOf(";", start) ;
alert('Stage 2-End is:'+end) ;
if (end == -1) end = allcookies.length ;
test = allcookies.substring(start, end) ;
alert('Stage 3-Test is:'+test) ;
return unescape(test) ;
}
}
function CheckSettings() {
var cookievalue = 0 ;
SetCookie('tmpCookie', 'Check');
cookievalue = GetCookie('tmpCookie') ;
alert('Stage Final-cookievalue:'+cookievalue) ;
if (cookievalue == 'Check') {
window.document.forms[0].elements['userid'].value = 'Enter Login ID';
document.LOGINFORM.userid.focus();
}
else {
window.document.forms[0].elements['userid'].value = 'Error';
}
}

Any help/info on this? Thanks