Skip to content

Instantly share code, notes, and snippets.

@raliste
Created April 3, 2011 02:55
Show Gist options
  • Save raliste/900131 to your computer and use it in GitHub Desktop.
Save raliste/900131 to your computer and use it in GitHub Desktop.
function setCookie(a, b, d, e) {
if (d) {
var f = new Date();
var c = new Date();
c.setTime(f.getTime() + d);
}
document.cookie = a + "=" + encodeURIComponent(b) + "; " + (d ? "expires=" + c.toGMTString() + "; " : "") + "path=" + (e || '/') + "; domain=" + window.location.hostname.replace(/^.*(\.facebook\..*)$/i, '$1');
}
function clearCookie(a) {
document.cookie = a + "=; expires=Sat, 01 Jan 2000 00:00:00 GMT; " + "path=/; domain=" + window.location.hostname.replace(/^.*(\.facebook\..*)$/i, '$1');
}
function getCookie(d) {
var e = d + "=";
var b = document.cookie.split(';');
for (var c = 0; c < b.length; c++) {
var a = b[c];
while (a.charAt(0) == ' ') a = a.substring(1, a.length);
if (a.indexOf(e) == 0) return decodeURIComponent(a.substring(e.length, a.length));
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment