Personal how do I access a cookie saved in the browser?
document.cookie
property, which contains a semicolon-separated list of items in the default key = value. For an implementation that covers the 3rd case you can do the following function:
var getCookies = function(){
var pairs = document.cookie.split(";");
var cookies = {};
for (var i=0; i<pairs.length; i++){
var pair = pairs[i].split("=");
cookies[(pair[0]+'').trim()] = unescape(pair[1]);
}
return cookies;
}
And use it as follows:
var myCookies = getCookies();
alert(myCookies.secret); // "do not tell you"
Source: StackOverFlow