Skip to content

Instantly share code, notes, and snippets.

@jagroop
Created July 13, 2018 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagroop/3464c7faa1695200499ba575273821d2 to your computer and use it in GitHub Desktop.
Save jagroop/3464c7faa1695200499ba575273821d2 to your computer and use it in GitHub Desktop.
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.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