---
title: "CookieJar.cookiesForURL(url) | Grafana k6 documentation"
description: "Get object with all cookies for the given URL, where the key is the cookie name and the value is an array."
---

# CookieJar.cookiesForURL(url)

Expand table

| Parameter | Type   | Description                 |
|-----------|--------|-----------------------------|
| url       | string | The URL to get cookies for. |

### Returns

Expand table

| Type   | Description                                                                                                 |
|--------|-------------------------------------------------------------------------------------------------------------|
| object | A JS object with all cookies for the given URL, where the key is the cookie name and the value is an array. |

### Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import http from 'k6/http';
import { check } from 'k6';

export default function () {
  const res = http.post('https://quickpizza.grafana.com/api/cookies?my_cookie=hello%20world', {
    redirects: 0,
  });
  const jar = http.cookieJar();
  const cookies = jar.cookiesForURL('https://quickpizza.grafana.com/api/cookies');
  check(res, {
    "has cookie 'my_cookie'": (r) => cookies.my_cookie.length > 0,
    'cookie has correct value': (r) => cookies.my_cookie[0] === 'hello world',
  });
}
```
