I need to make my cookies undeletable by saving the value. I mean , if I deleted cookie in browser then I refreshed page, the value shouldn't be changed from current to 1 .It must be saved and continue counts like nothing happened.
var startButton = document.getElementById('start-button');
var counterAttemps = 0;
var maxAttemps = 10;
function ad(){
value = getCookie("counterAttemps");
vl = parseInt(value , 10);
vl = vl + counterAttemps;
if(vl >= 1){
counterAttemps = vl;
}
}
function checkCookie(){
ad();
}
startButton.onclick = function(){
if(counterAttemps < maxAttemps){
setCookie("counterAttemps" , counterAttemps , 1);
}
counterAttemps++;
}
window.onload = checkCookie();
You'll have to store the user session externally with a server. Unfortunately the user has ultimate control over his/her browser cookies.