I am storing a cookie on one page, with inputs in a form with this function:
<script type="text/javascript">
function WriteCookie()
{
emailValue = escape(document.form.01_email.value) + ";";
userIDValue = escape(document.form.01_userID.value) + ";";
document.cookie="email=" + emailValue;
document.cookie="userID=" + userIDValue;
}
</script>
<form name="form">
<input type="email" class="form-textbox validate[required, Email]" id="input_10" name="01_email" size="26" value="email@email.com" />
<input type="hidden" id="simple_spc" name="01_userId" value="1234" />
</form>
I get redirect to another page once a user submits the form, and I retrieve the cookie with this code but i need to have it find the email and userID in the cookie and insert it in the value of the inputs on this new page:
<script type="text/javascript">
function ReadCookie()
{
var allcookies = document.cookie;
alert("All Cookies : " + allcookies );
// Get all the cookies pairs in an array
cookiearray = allcookies.split(';');
// Now take key value pair out of this array
for(var i=0; i<cookiearray.length; i++){
name = cookiearray[i].split('=')[1];
value = cookiearray[i].split('=')[2];
alert("Email is : " + name + " and UserID is : " + value);
}
}
</script>
<form name="form">
<input type="email" class="form-textbox" id="input_10" name="02_email" size="26" value="" />
<input type="hidden" id="simple_spc" name="02_userId" value="" />
</form>
I know a user will most likely have multiple cookies, so finding only the email and userID i’m having trouble with.
Try this to read your cookies.