JavaScript Code

How to get all cookies for the web page?

Tutorials using JS

Problem Statement

get all cookies for the document/web-page


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


<!DOCTYPE html>
<div id="output"></div>

var cookies = document.cookie;
document.getElementById('output').innerHTML = cookies;


Copyright @2022