When i refresh the browser, the timer resets, so how to make it not reset? This is my code. Please check it.
<?php echo $waktune; ?> // You can change it into seconds
var detik = <?php echo $waktune; ?>;
if (document.images) {
parselimit = detik
}
function begintimer() {
if (!document.images)
return
if (parselimit < 12) {
document.getElementById("servertime").style.color = "Green";
}
if (parselimit == 1) {
document.getElementById("hasil").submit();
} else {
parselimit -= 1 curmin = Math.floor(parselimit / 60)
cursec = parselimit % 60
if (curmin != 0)
curtime = curmin + ":" + cursec + ""else
curtime = cursec + " detik"document.getElementById("servertime").innerHTML = curtime setTimeout("begintimer()", 1000)
}
}
You can use local storage, such as :
Store the server time in a cookie (see setcookie) and load that. You'll want to think about how long you want this cookie to last though.
Try to use local storage :
Update
Example :
Source: http://chandreshrana.blogspot.in/2017/01/how-to-make-counter-not-reset-on-page.html
I think you have to save some value in the cookie and reset timer only if timer > x && cookie is already been setted.
Set cookie on init:
Set cookie on reaload:
Check: