Okay, that's quite simple with the code you've tried. You just need to set the flag in the cookie, and set a timeout to check if the cookie has expired or not.
You can find the methods that allows you to get and set cookies from here -
JavaScript Cookies[
^]
JavaScript setTimeout() -
JavaScript Timing Events[
^]
function countClicks() {
var clickLimit = 3;
if(ClickCount>=clickLimit) {
alert("You can only click this button "+clickLimit+" times.");
return false;
}
else
{
ClickCount++;
return true;
}
}
setTimeout(function(){
}, 1000);
I hope you get the idea.
KR