I'm trying to detect the existence of a specific cookie "abc". The code that I'm using for this is
var iterations = 0;
var interval = setInterval(checkCookie, 1000);
var cookie=getCookie("abc");
function checkCookie() {
iterations++;
if (iterations >= 3 || cookie !=null || cookie !="")
clearInterval(interval);
alert("Iteration " + iterations );
}
The only problem with this code is that it doesn't detect the existence of a cookie. Even when I change the cookie name to one that already exists.You can check it out here http://jsfiddle.net/aMZj3/