Read cookies with JavaScript
Posted
by Etienne
on Stack Overflow
See other posts from Stack Overflow
or by Etienne
Published on 2010-05-25T13:39:44Z
Indexed on
2010/05/25
14:01 UTC
Read the original article
Hit count: 388
I know how to write cookies in JavaScript
//Create the cookies
document.cookie = "Name=" + Name + ";expires=Friday, 31-Dec-2011 12:00:00 GMT; path=/";
document.cookie = "Surname=" + Surname + ";expires=Friday, 31-Dec-2011 12:00:00 GMT; path=/";
document.cookie = "Number=" + Number + ";expires=Friday, 31-Dec-2011 12:00:00 GMT; path=/";
document.cookie = "Email=" + Email + ";expires=Friday, 31-Dec-2011 12:00:00 GMT; path=/";
document.cookie = "Country=" + Country + ";expires=Friday, 31-Dec-2011 12:00:00 GMT; path=/";
document.cookie = "Company=" + Company + ";expires=Friday, 31-Dec-2011 12:00:00 GMT; path=/";
document.cookie = "Title=" + Job + ";expires=Friday, 31-Dec-2011 12:00:00 GMT; path=/";
But how can I read each one of them in JavaScript because I want to populate the text boxes next time the user come to the form?
I have tried this but it does not work............
var cookieName = ReadCookie("Name");
document.getElementById('txtName').value = cookieName;
Thanks in advanced!!
© Stack Overflow or respective owner