I am checking to see if a url contains the word "rewrite", if it does I am adding a cookie. However, I want to reload the page after the cookie is added, then stop reloading the page. Currently it keeps reloading the page because it sees the url and it contains the word "rewrite". Is there like a Do Once
in jQuery or a Stop()
method? Perhpas I have to use .live()?
$(document).ready(function () {
if ($.cookie('logged_in') == null) {
Do Nothing
} else {
Do Something
}
});
$(document).ready(function () {
if (/rewrite/.test(self.location.href)) {
$.cookie("logged_in", 1, { expires : 1 });
location.reload(); stop();
}
});
SOLVED
if (/rewrite/.test(self.location.href)) {
if ($.cookie('logged_in') == null) {
$.cookie("logged_in", 1, { expires : 1 });
location.reload();
}