{
  "doc": {
    "id": "api/commands/clearcookie",
    "title": "clearCookie | Cypress Documentation",
    "description": "Clear a specific browser cookie in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/clearcookie.md",
    "version": "24a73f8a97175663aaffd3b016289fb2a523a4ea",
    "updated_at": "2026-05-14T20:17:33.301Z",
    "headings": [
      {
        "id": "api/commands/clearcookie#clearcookie",
        "text": "clearCookie",
        "level": 1
      },
      {
        "id": "api/commands/clearcookie#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/clearcookie#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/clearcookie#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/clearcookie#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/clearcookie#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/clearcookie#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/clearcookie#clear-a-cookie-after-logging-in",
        "text": "Clear a cookie after logging in[",
        "level": 4
      },
      {
        "id": "api/commands/clearcookie#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/clearcookie#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/clearcookie#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/clearcookie#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/clearcookie#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/clearcookie#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/clearcookie#syntax",
      "doc_id": "api/commands/clearcookie",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.clearCookie(name)cy.clearCookie(name, options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.clearCookie('authId') // clear the 'authId' cookie\n```\n\n### Arguments\n\n**name _(String)_**\n\nThe name of the cookie to be cleared.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.clearCookie()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `domain` | Hostname of the current URL | Clears the cookie from the specified domain |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`responseTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.clearCookie()` to resolve before [timing out](#Timeouts) |\n\n### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n*   `cy.clearCookie()` yields `null`.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 152
    },
    {
      "id": "api/commands/clearcookie#arguments",
      "doc_id": "api/commands/clearcookie",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**name _(String)_**\n\nThe name of the cookie to be cleared.\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.clearCookie()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `domain` | Hostname of the current URL | Clears the cookie from the specified domain |\n| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |\n| `timeout` | [`responseTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `cy.clearCookie()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 115
    },
    {
      "id": "api/commands/clearcookie#examples",
      "doc_id": "api/commands/clearcookie",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### No Args\n\n#### Clear a cookie after logging in[\n\nEnd-to-End Only\n\n](/llm/markdown/app/core-concepts/testing-types.md#What-is-E2E-Testing)\n\nIn 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.\n\n```\n// 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')\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 97
    },
    {
      "id": "api/commands/clearcookie#no-args",
      "doc_id": "api/commands/clearcookie",
      "heading": "No Args",
      "heading_level": 3,
      "content_markdown": "### No Args\n\n#### Clear a cookie after logging in[\n\nEnd-to-End Only\n\n](/llm/markdown/app/core-concepts/testing-types.md#What-is-E2E-Testing)\n\nIn 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.\n\n```\n// 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')\n```\n",
      "section": "api",
      "anchors": [
        "no-args"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 95
    },
    {
      "id": "api/commands/clearcookie#clear-a-cookie-after-logging-in",
      "doc_id": "api/commands/clearcookie",
      "heading": "Clear a cookie after logging in[",
      "heading_level": 4,
      "content_markdown": "#### Clear a cookie after logging in[\n\nEnd-to-End Only\n\n](/llm/markdown/app/core-concepts/testing-types.md#What-is-E2E-Testing)\n\nIn 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.\n\n```\n// 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')\n```\n",
      "section": "api",
      "anchors": [
        "clear-a-cookie-after-logging-in"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 91
    },
    {
      "id": "api/commands/clearcookie#rules",
      "doc_id": "api/commands/clearcookie",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)\n\n*   `cy.clearCookie()` requires being chained off of `cy`.\n\n### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)\n\n*   `cy.clearCookie()` cannot have any assertions chained.\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.clearCookie()` should never time out.\n\nBecause `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.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 92
    },
    {
      "id": "api/commands/clearcookie#timeouts-learn-about-timeouts",
      "doc_id": "api/commands/clearcookie",
      "heading": "Timeouts Learn about timeouts",
      "heading_level": 3,
      "content_markdown": "### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.clearCookie()` should never time out.\n\nBecause `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.\n",
      "section": "api",
      "anchors": [
        "timeouts-learn-about-timeouts"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 55
    },
    {
      "id": "api/commands/clearcookie#command-log",
      "doc_id": "api/commands/clearcookie",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Clearing a cookie after setting a cookie_**\n\n```\ncy.setCookie('foo', 'bar')cy.clearCookie('foo')cy.getCookie('foo').should('be.null')\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `clearCookie` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookie.json",
      "token_estimate": 49
    }
  ]
}