---
title: "List all cookies with JavaScript"  
description: "List all cookies with JavaScript"  
author: "Anonymous User"  
published: 2021-07-19  
updated: 2021-07-19  
canonical: https://www.mindstick.com/forum/156526/list-all-cookies-with-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# List all cookies with JavaScript

How can I list all [cookies](https://www.mindstick.com/articles/12044/cookies-in-c-sharp) with [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript)?

## Replies

### Reply by Anonymous User

Read a Cookie with JavaScript

With JavaScript, cookies can be read like this:

```
let x = document.cookie;
```

document.cookie will return all cookies in one string much like: cookie1=value; cookie2=value; cookie3=value;

You can list cookies for the current domain:

```
function listCookies() {
    var theCookies = document.cookie.split(';');
    var aString = '';
    for (var i = 1 ; i <= theCookies.length; i++) {
        aString += i + ' ' + theCookies[i-1] + '\n';
    }
    return aString;
}
```

But you cannot list cookies for other domains for security reasons


---

Original Source: https://www.mindstick.com/forum/156526/list-all-cookies-with-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
