---
id: api/commands/getallcookies
title: cy.getAllCookies()
description: Get all browser cookies in Cypress.
section: api
source_path: docs/api/commands/getallcookies.mdx
version: dedb0779b5aa1e810bd6355ebd857ee7cbf9124c
updated_at: '2026-09-21T02:48:59.990Z'
---
# getAllCookies

Get all browser cookies.

## Syntax

```
cy.getAllCookies()
cy.getAllCookies(options)
```

### Usage

**Correct Usage**

```
cy.getAllCookies() // Get all cookies
```

### Arguments

**options _(Object)_**

Pass in an options object to change the default behavior of `cy.getAllCookies()`.

| Option | Default | Description |
| --- | --- | --- |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.getAllCookies()` to resolve before [timing out](#Timeouts) |

### Yields

`cy.getAllCookies()` yields an array of cookie objects. Each cookie object has the following properties:

*   `domain`: _(String)_
*   `expiry`: _(Number)_ _(if specified)_
*   `hostOnly`: _(Boolean)_ _(if specified)_
*   `httpOnly`: _(Boolean)_
*   `name`: _(String)_
*   `path`: _(String)_
*   `sameSite`: _(String)_ _(if specified)_
*   `secure`: _(Boolean)_
*   `value`: _(String)_

`cy.getAllCookies()` is a query, and it is _safe_ to chain further commands. It will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed, or until it times out, re-reading the cookies from all domains on each retry so the yielded array stays up to date.

Because `cy.getAllCookies()` is a query, it re-reads the cookies on every retry, and assertions you chain with [`.should()`](/llm/markdown/api/commands/should.md) drive those retries until they pass or the command times out. A [`.then()`](/llm/markdown/api/commands/then.md) callback, by contrast, runs only once after the command settles and is not retried — so prefer chaining [`.should()`](/llm/markdown/api/commands/should.md) assertions over asserting inside `.then()` when you need Cypress to wait for the cookies to be set.

#### When no cookies are present:

On each read, `cy.getAllCookies()` yields the current array of cookie objects, or an empty array if none exist yet. The yielded array is the subject your chained assertions run against. If an assertion fails, because the array is empty, or because its contents don't match yet, the query re-reads the cookies and re-runs the assertion, looping until it passes or the command times out.

## Examples

### Get Cookies

#### Get cookies after logging in

In this example, we log in through an identity provider which sets a cookie and redirects back to our site, which sets a session cookie.

```
cy.contains('Log in').click()
cy.origin('https://example.cypress.io', () => {
  cy.get('[type=password]').type('*****')
  cy.contains('Log in').click()
})
cy.url().should('include', 'profile')
cy.getAllCookies()
  .should('have.length', 2)
  .then((cookies) => {
    expect(cookies[0]).to.have.property('name', 'identity_session_id')
    expect(cookies[1]).to.have.property('name', 'session_id')
  })
```

## Rules

### Requirements

*   `cy.getAllCookies()` requires being chained off of `cy`.

### Assertions

*   `cy.getAllCookies()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.

### Timeouts

*   `cy.getAllCookies()` can time out waiting for assertions you've added to pass.

## History

| Version | Changes |
| --- | --- |
| [16.0.0](/llm/markdown/app/references/changelog.md#16-0-0) | `cy.getAllCookies()` is now a query and retries assertions until they pass or time out. |

## See also

*   [`cy.clearAllCookies()`](/llm/markdown/api/commands/clearallcookies.md)
*   [`cy.clearCookie()`](/llm/markdown/api/commands/clearcookie.md)
*   [`cy.clearCookies()`](/llm/markdown/api/commands/clearcookies.md)
*   [`cy.getCookie()`](/llm/markdown/api/commands/getcookie.md)
*   [`cy.setCookie()`](/llm/markdown/api/commands/setcookie.md)
*   [`Cypress.Cookies.debug()`](/llm/markdown/api/cypress-api/cookies.md)
