I learning JavaScript and doing something wrong here, what I want to
do is store the contents of a variable to a cookie so that it would
show the next time the page was opened. I'm doing something wrong in
the code below because instead of saving the value of nLastBonus to
the cookie I'm saving "nLastBonus".
Can someone point me in the right direction?
// Get the cookie
var nLastBonus = get_cookie()
// Did the cookie exist?
if (nLastBonus) {
// If not, then store 100 to nLastBonus
// visit_number = 1
nLastBonus = 100
}
else {
// Otherwise, increment nLastBonus
nLastBonus++
}
// Set the cookie
document.cookie="last_bonus=nLastBonus; expires=" + expire_string