Home > document.cookies

document.cookies

Document.cookies is a project mainly written in JavaScript, it's free.

Better way to read cookies in JavaScript

Do you have the same feeling that using cookies in JavaScript is painful? If yes, you will probably like this script. The script offers a plain JavaScript object containing all stored cookies in form {cookieName:"cookieValue"}. The script automatically updates the object when you write new cookies, update some cookies or delete ones.

To use this script just link the script in HEAD section of your document

... and then use it in your scripts.

if(document.cookies['test']){ console.log(document.cookies.test); } else { console.log("The cookie 'test' doesn't exist"); }