Skip to content

Instantly share code, notes, and snippets.

@baki250
Last active August 23, 2016 12:55
Show Gist options
  • Save baki250/87fa327396427dbe8070b0bcf8495532 to your computer and use it in GitHub Desktop.
Save baki250/87fa327396427dbe8070b0bcf8495532 to your computer and use it in GitHub Desktop.
Read cookie
This function reads a cookie from the visitor's browser and returns the value.
Example Javascript
/*
* Usage
* This function will return the value of the cookie name passed in as the argument.
*
* @param {String} name - The name of the cookie.
*/
var getCookie = function(name) {
var match = document.cookie.match(name+'=([^;]*)');
return match ? match[1] : undefined;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment