---
id: api/commands/clearcookie
title: clearCookie | Cypress Documentation
description: Clear a specific browser cookie in Cypress.
section: api
source_path: docs/api/commands/clearcookie.mdx
version: 7ada28c0cd90e81cf56fd3fc73de6e6d45c16de6
updated_at: '2026-05-13T21:55:41.935Z'
---
# clearCookie

Clear a specific browser cookie.

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 a specific cookie inside a single test or test isolation is disabled.

## Syntax

```
cy.clearCookie(name)cy.clearCookie(name, options)
```

### Usage

**Correct Usage**

```
cy.clearCookie('authId') // clear the 'authId' cookie
```

### Arguments

**name _(String)_**

The name of the cookie to be cleared.

**options _(Object)_**

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

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

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

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

## Examples

### No Args

#### Clear a cookie 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.clearCookie('session_id')`, this clears the session cookie. Then upon navigating to an unauthorized page, we asset that our server has redirected us back to login.

```
// assume we just logged incy.contains('Login').click()cy.url().should('include', 'profile')cy.clearCookie('session_id')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.clearCookie()` requires being chained off of `cy`.

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

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

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

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

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

**_Clearing a cookie after setting a cookie_**

```
cy.setCookie('foo', 'bar')cy.clearCookie('foo')cy.getCookie('foo').should('be.null')
```

The commands above will display in the Command Log as:

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

## See also

*   [`cy.clearCookies()`](/llm/markdown/api/commands/clearcookies.md)
*   [`cy.clearLocalStorage()`](/llm/markdown/api/commands/clearlocalstorage.md)
*   [`cy.getCookies()`](/llm/markdown/api/commands/getcookies.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)
