Skip to content

Instantly share code, notes, and snippets.

@anthonybudd
Created July 26, 2017 17:06
Show Gist options
  • Save anthonybudd/a2cbec6119a9fd528ea129f4a7ac8b63 to your computer and use it in GitHub Desktop.
Save anthonybudd/a2cbec6119a9fd528ea129f4a7ac8b63 to your computer and use it in GitHub Desktop.
function hasSeenBreakingNewsBanner(){
var name = "has_seen_breaking_news_banner" + "=";
var cookies = document.cookie.split(';');
for(var i = 0; i < cookies.length; i++){
var cookie = cookies[i];
while(cookie.charAt(0) == ' ') {
cookie = cookie.substring(1);
}
if(cookie.indexOf(name) == 0){
return true;
}
}
return false;
}
function setSeenBreakingNewsBanner(){
var date = new Date();
date.setTime(date.getTime() + (24 * 60 * 60 * 1000));
document.cookie = "has_seen_breaking_news_banner" + "=" + "1" + ";" + ("expires=" + date.toUTCString()) + ";path=/";
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment