Skip to content

Instantly share code, notes, and snippets.

@NicolasPio
Created September 23, 2014 15:10
Show Gist options
  • Select an option

  • Save NicolasPio/15e2a438e695fbc0d682 to your computer and use it in GitHub Desktop.

Select an option

Save NicolasPio/15e2a438e695fbc0d682 to your computer and use it in GitHub Desktop.
function getCookieByName(name){
var cookies,
cookie,
endValue,
value;
cookies = document.cookie;
cookies = cookies.split('; ' + name + '=');
if(typeof cookies[1] != 'undefined'){
cookie = cookies[1];
}else{
cookie = cookies[0];
}
endValue = cookie.indexOf(';');
value = cookie.substr(0, endValue);
return value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment