I have a web page that sets a variable into a cookie and then another page then loads the cookie data and places it in random places on the page. I’m using it right now to hold the name of the particular person visiting the page. I want to use two different variables instead of just one however, so as to hold a number for another script I have. Anyone got ideas?
This is the code that sets the cookie:
[CODE]expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+12)
visitid = “”
if (document.cookie != “”) {
visitid = document.cookie.split(“=”)[1]}
function setCookie() {
visitid = document.myForm.nameField.value
document.cookie = “visitid=”+visitid + expireDate.toGMTString()
}
The form named above as “myForm” is the textbox that the user puts their name into.
Then there’s the code that reads it:
[CODE]if (document.cookie !=””) {
var username = (document.cookie.split(“=”)[1])
}
and then all over the page i just put this in:
[CODE]document.write(username)