samedi 27 décembre 2014

How do you read boolean values from cookies?


Here's my current cookie function so far:



function getCookie(name, type) {
var nameEQ = name + "=";
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,c.length);
x = c.substring(nameEQ.length,c.length);
if (type=="Bool") {
if (c.indexOf(name) == 0) return x;
} else {
if (c.indexOf(name) == 0) return parseInt(x);
}
}
return 0;
}


However, the boolean values don't return correctly. The integer values do, though. If someone could help that would be awesome, I've been searching for 30 minutes, and still haven't found the answer.





Aucun commentaire:

Enregistrer un commentaire