Skip to content

Instantly share code, notes, and snippets.

@raphaelchaib
Created June 28, 2016 04:50
Show Gist options
  • Save raphaelchaib/791acb6b04f4692da7dafe936a71432a to your computer and use it in GitHub Desktop.
Save raphaelchaib/791acb6b04f4692da7dafe936a71432a to your computer and use it in GitHub Desktop.
Javascript: Read cookie value
function read_cookie(key){
var result;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? (result[1]) : null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment