public
Last active

js :: get cookie value

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7
// include jQuery before writing this function
// setting cookie example
// document.cookie = 'a=' + 10 + ';b=' + 20;
var getCookie = function (name) {
var val = $.map($.grep(document.cookie.split(';'), function (v) { return v.indexOf(name) !== -1; }), function (v) { return v.split('=')[1]; });
return val[0];
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.