Tutorials using JS
Problem Statement
get all cookies for the document/web-page
Solution
to get all the cookies currently present for the document, use document.cookie
. cookie property returns a semicolon separated list of name-value pairs as shown in the following
key1=value1; key2=value2; key3=value3
Program
<!DOCTYPE html>
<html>
<body>
<h1>Cookies</h1>
<div id="output"></div>
<script>
var cookies = document.cookie;
document.getElementById('output').innerHTML = cookies;
</script>
</body>
</html>