---
id: api/commands/clearcookies
title: clearCookies | Cypress Documentation
description: Clear browser cookies for a domain in Cypress.
section: api
source_path: docs/api/commands/clearcookies.mdx
version: 24a73f8a97175663aaffd3b016289fb2a523a4ea
updated_at: '2026-05-14T20:17:33.301Z'
---
# clearCookies

Clear browser cookies for a domain.

Cypress automatically clears all cookies _before_ each test to prevent state from being shared across tests when [test isolation](/llm/markdown/app/core-concepts/writing-and-organizing-tests.md#Test-Isolation) is enabled. You shouldn't need to use this command unless you're using it to clear specific cookies inside a single test or test isolation is disabled.

## Syntax

```
cy.clearCookies()cy.clearCookies(options)
```

### Usage

**Correct Usage**

```
cy.clearCookies() // Clear cookies for the currrent domain
```

### Arguments

**options _(Object)_**

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

| Option | Default | Description |
| --- | --- | --- |
| `domain` | Hostname of the current URL | Clears 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.clearCookies()` to resolve before [timing out](#Timeouts) |

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

*   `cy.clearCookies()` yields `null`.

## Examples

### No Args

#### Clear cookies after logging in[

End-to-End Only

](/llm/markdown/app/core-concepts/testing-types.md#What-is-E2E-Testing)

In this example, on first login our server sends us back a session cookie. After invoking `cy.clearCookies()` this clears the session cookie, and upon navigating to an unauthorized page, our server should have redirected us back to login.

```
// assume we just logged incy.contains('Login').click()cy.url().should('include', 'profile')cy.clearCookies()cy.visit('/dashboard') // we should be redirected back to logincy.url().should('include', 'login')
```

## Rules

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

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

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

*   `cy.clearCookies()` cannot have any assertions chained.

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

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

Because `cy.clearCookies()` 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

**_Clear cookies after getting cookies_**

```
cy.getCookies().should('have.length', 1)cy.clearCookies()cy.getCookies().should('be.empty')
```

The commands above will display in the Command Log as:

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

## See also

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