How can I store an integer that the user clicks on the button is incremented only by section (for that I use sessionStorage
) but this incremented value is visible to everyone on the internet, not just the cookie. This is the code I use:
function clickCounter() {
if(typeof(Storage) !== "undefined") {
if (localStorage.clickcount) {
if (!sessionStorage.voted) {
localStorage.clickcount = Number(localStorage.clickcount)+1;
} else {
jaVotou()
}
} else {
localStorage.clickcount = 1;
}
sessionStorage.voted = 1;
document.getElementById("result").innerHTML = countString();
document.getElementById("botao").innerHTML = "<center><button onclick=\"clickCounter()\" class=\"myButton\" type=\"Button\">Obrigado</button></center>"
} else {
document.getElementById("result").innerHTML = "Navegador não suportado";
}
}
But by clearing your browser's browsing data these values are cleared. How do I prevent this from happening?