Created
January 31, 2020 15:54
-
-
Save dsheiko/7a7126467357cd3f969335f5d74d5adb to your computer and use it in GitHub Desktop.
Gt cookies by name with JavaScript
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 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