I'm trying to change the background colour of the watch face on touch event. I want to record the user choice and use that after the user turns off the device. I implemented touch events with no problems and they work, but cookies won't work.
this is the code :
var bottone = document.getElementById('bottone');
/* touchend event */
bottone.addEventListener('touchend', function() {
color = getCookie("color");
console.log(color);
if (color == null || color == 3){
document.getElementById("overlay").style.backgroundImage = "url('/image/bg_1.png')";
setCookie('color','1',365);
}else if (color == 1){
document.getElementById("overlay").style.backgroundImage = "url('/image/bg_2.png')";
setCookie('color','2',365);
}else if (color == 2){
document.getElementById("overlay").style.backgroundImage = "url('/image/bg_3.png')";
setCookie('color','3',365);
}
}, false);
the console.log(color) return null every time I click id="bottone"
This is the code for cookies: