D
Dave Vick
Hey all:
I've got the following code snippet in a function to set a coockie based
on whether or not the user selects a checkbox. Using an alert the cookie
text looks fine but when I go to retrieve the values the only one it can
find is the value for user. I've a few different things and none of them
seem to work. I'm getting the same thing in both IE and Firefox. The
only cookie listed is the 'user' with the proper expiration date.
The code:
var currDate = new Date();
var cookieText = "user=" + escape(document.login.user_email.value);
cookieText += "; pw=" + escape(document.login.user_password.value);
cookieText += "; setDate=" + currDate.toGMTString();
// expires in one year
currDate.setFullYear(currDate.getFullYear() + 1);
cookieText += "; expires=" + currDate.toGMTString();
document.cookie = cookieText;
document.login.submit();
However, setting each name value pair as their own cookie seems to work
fine. As I do here:
var currDate = new Date();
var setDate = currDate.toGMTString();
var expDate = new Date(currDate.setFullYear(currDate.getFullYear() + 1));
expDate = expDate.toGMTString();
// set user cookie
var cookieText = "user=" + escape(document.login.user_email.value);
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
// set password cookie
cookieText = "pw=" + escape(document.login.user_password.value);
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
// set setDate cookie
cookieText = "setDate=" + setDate;
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
document.login.submit();
As far as I know the first way should work too, anyone know why it
isn't? Am I doing something wrond and just not seeing it?
Thanks for any input.
Dave
I've got the following code snippet in a function to set a coockie based
on whether or not the user selects a checkbox. Using an alert the cookie
text looks fine but when I go to retrieve the values the only one it can
find is the value for user. I've a few different things and none of them
seem to work. I'm getting the same thing in both IE and Firefox. The
only cookie listed is the 'user' with the proper expiration date.
The code:
var currDate = new Date();
var cookieText = "user=" + escape(document.login.user_email.value);
cookieText += "; pw=" + escape(document.login.user_password.value);
cookieText += "; setDate=" + currDate.toGMTString();
// expires in one year
currDate.setFullYear(currDate.getFullYear() + 1);
cookieText += "; expires=" + currDate.toGMTString();
document.cookie = cookieText;
document.login.submit();
However, setting each name value pair as their own cookie seems to work
fine. As I do here:
var currDate = new Date();
var setDate = currDate.toGMTString();
var expDate = new Date(currDate.setFullYear(currDate.getFullYear() + 1));
expDate = expDate.toGMTString();
// set user cookie
var cookieText = "user=" + escape(document.login.user_email.value);
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
// set password cookie
cookieText = "pw=" + escape(document.login.user_password.value);
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
// set setDate cookie
cookieText = "setDate=" + setDate;
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
document.login.submit();
As far as I know the first way should work too, anyone know why it
isn't? Am I doing something wrond and just not seeing it?
Thanks for any input.
Dave