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_ema il.value);
cookieText += "; pw=" + escape(document .login.user_pas sword.value);
cookieText += "; setDate=" + currDate.toGMTS tring();
// expires in one year
currDate.setFul lYear(currDate. getFullYear() + 1);
cookieText += "; expires=" + currDate.toGMTS tring();
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.toGMTS tring();
var expDate = new Date(currDate.s etFullYear(curr Date.getFullYea r() + 1));
expDate = expDate.toGMTSt ring();
// set user cookie
var cookieText = "user=" + escape(document .login.user_ema il.value);
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
// set password cookie
cookieText = "pw=" + escape(document .login.user_pas sword.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_ema il.value);
cookieText += "; pw=" + escape(document .login.user_pas sword.value);
cookieText += "; setDate=" + currDate.toGMTS tring();
// expires in one year
currDate.setFul lYear(currDate. getFullYear() + 1);
cookieText += "; expires=" + currDate.toGMTS tring();
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.toGMTS tring();
var expDate = new Date(currDate.s etFullYear(curr Date.getFullYea r() + 1));
expDate = expDate.toGMTSt ring();
// set user cookie
var cookieText = "user=" + escape(document .login.user_ema il.value);
cookieText += "; expires=" + expDate;
document.cookie = cookieText;
// set password cookie
cookieText = "pw=" + escape(document .login.user_pas sword.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
Comment