Skip to content

Instantly share code, notes, and snippets.

@dsheiko
Created January 31, 2020 15:54
Show Gist options
  • Save dsheiko/7a7126467357cd3f969335f5d74d5adb to your computer and use it in GitHub Desktop.
Save dsheiko/7a7126467357cd3f969335f5d74d5adb to your computer and use it in GitHub Desktop.
Gt cookies by name with JavaScript
function getCookie( name ) {
const value = "; " + document.cookie,
parts = value.split( "; " + name + "=" );
if ( parts.length === 2 ) {
return parts.pop().split( ";" ).shift();
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment