How do I load multiple variables from one cookie file?
I have tried this:
if (variable1 != null) {
variable1 = getCookie("variable1");
variable2 = getCookie("variable2");
variable3 = getCookie("variable3");
} else {
variable1 = 0;
variable2 = 0;
variable3 = 0;
}
but that doesn't seem to work.
And this is how the getCookie function looks like:
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
}