Skip to content

Instantly share code, notes, and snippets.

@py7hon
Created December 25, 2018 11:59
Show Gist options
  • Save py7hon/ad3b584fede43a4d8d2fb1797ec7b324 to your computer and use it in GitHub Desktop.
Save py7hon/ad3b584fede43a4d8d2fb1797ec7b324 to your computer and use it in GitHub Desktop.
random subdomain like akurat.co
function setCookie(cname, cvalue, ex) {
var d = new Date();
d.setTime(d.getTime() + (ex*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 "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment