I need to get all the cookies stored in my browser using JavaScript. How can it be done?
You can only access cookies for a specific site. Using document.cookie you will get a list of escaped key=value pairs seperated by a semicolon.
secret=do%20not%20tell%you;last_visit=1225445171794
To simplify the access, you have to parse the string and unescape all entries:
var getCookies = function(){
var pairs = document.cookie.split(";");
var cookies = {};
for (var i=0; i
So you might later write:
var myCookies = getCookies();
alert(myCookies.secret); // "do not tell you"