Last active
November 28, 2019 15:40
-
-
Save erikpantzar/f182e610aaab1109e2cd0a257af536c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setCookie(cname, cvalue, exdays) { | |
var d = new Date(); | |
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); | |
var expires = "expires="+d.toUTCString(); | |
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; | |
} | |
function getCookie(cname) { | |
var name = cname + "="; | |
var ca = document.cookie.split(';'); | |
for(var i = 0; i < ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0) == ' ') { | |
c = c.substring(1); | |
} | |
if (c.indexOf(name) == 0) { | |
return c.substring(name.length, c.length); | |
} | |
} | |
return ""; // HAS NO COOKIE | |
} | |
const THE_COOKIE_NAME = 'hasSeenBlackFriday2019' | |
if (getCookie(THE_COOKIE_NAME) === 'seen') { | |
if (getCookie(THE_COOKIE_NAME) !== "") { | |
// DO NOT SHOW POPUP!!! | |
} else { | |
// SHOW POPUP!! | |
// THEN SET COOKIE | |
setCookie(THE_COOKIE_NAME, 'seen', 30) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hihihih