---
id: api/commands/getcookies
title: getCookies | Cypress Documentation
description: Get browser cookies for the current domain or the specified domain in Cypress.
section: api
source_path: docs/api/commands/getcookies.mdx
version: 204dffbf7fbb64b1fe8343a54ddcd869cc275f1f
updated_at: '2026-05-12T20:33:17.938Z'
---
# getCookies

Get browser cookies for the current domain or the specified domain.

## Syntax

```
cy.getCookies()cy.getCookies(options)
```

### Usage

**Correct Usage**

```
cy.getCookies() // Get cookies for the currrent domain
```

### Arguments

**options _(Object)_**

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

| Option | Default | Description |
| --- | --- | --- |
| `domain` | Hostname of the current URL | Retrieves the cookies from the specified domain |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `timeout` | [`responseTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.getCookies()` to resolve before [timing out](#Timeouts) |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

`cy.getCookies()` 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.getCookies()` is not a query. It will not update the returned list if further cookies are added after it initially executes.

## Examples

### Get Cookies

#### Get cookies after logging in

In this example, on first login our server sends us back a session cookie.

```
// assume we just logged incy.contains('Login').click()cy.url().should('include', 'profile')cy.getCookies()  .should('have.length', 1)  .then((cookies) => {    expect(cookies[0]).to.have.property('name', 'session_id')  })
```

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

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

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `cy.getCookies()` will only run assertions you have chained once, and will not [retry](/llm/markdown/app/core-concepts/retry-ability.md).

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `cy.getCookies()` should never time out.

Because `cy.getCookies()` is asynchronous it is technically possible for there to be a timeout while talking to the internal Cypress automation APIs. But for practical purposes it should never happen.

## Command Log

**_Get browser cookies and inspect all properties_**

```
cy.getCookies()  .should('have.length', 1)  .then((cookies) => {    expect(cookies[0]).to.have.property('name', 'fakeCookie1')    expect(cookies[0]).to.have.property('value', '123ABC')    expect(cookies[0]).to.have.property('domain')    expect(cookies[0]).to.have.property('httpOnly')    expect(cookies[0]).to.have.property('path')    expect(cookies[0]).to.have.property('secure')  })
```

The commands above will display in the Command Log as:

When clicking on `getCookies` within the command log, the console outputs the following:

## History

| Version | Changes |
| --- | --- |
| [5.0.0](/llm/markdown/app/references/changelog.md#5-0-0) | Removed `experimentalGetCookiesSameSite` and made `sameSite` property always available. |
| [4.3.0](/llm/markdown/app/references/changelog.md#4-3-0) | Added `sameSite` property when the [experimentalGetCookiesSameSite](/llm/markdown/app/references/configuration.md#Experiments) configuration value is `true`. |

## See also

*   [`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)
