{
  "doc": {
    "id": "api/commands/clearcookies",
    "title": "cy.clearCookies()",
    "description": "Clear browser cookies for a domain in Cypress.",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/clearcookies.md",
    "version": "5a232a3cf094b8f928b1179ce5af6a5046296fac",
    "updated_at": "2026-11-13T01:14:31.437Z",
    "headings": [
      {
        "id": "api/commands/clearcookies#clearcookies",
        "text": "clearCookies",
        "level": 1
      },
      {
        "id": "api/commands/clearcookies#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/clearcookies#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#yields",
        "text": "Yields",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/clearcookies#no-args",
        "text": "No Args",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#clear-cookies-after-logging-in",
        "text": "Clear cookies after logging in[",
        "level": 4
      },
      {
        "id": "api/commands/clearcookies#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/clearcookies#default-cookie-domain-before-visiting-a-page",
        "text": "Default cookie domain before visiting a page",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/clearcookies#requirements",
        "text": "Requirements",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#assertions",
        "text": "Assertions",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#timeouts",
        "text": "Timeouts",
        "level": 3
      },
      {
        "id": "api/commands/clearcookies#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/clearcookies#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/clearcookies#syntax",
      "doc_id": "api/commands/clearcookies",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.clearCookies()\ncy.clearCookies(options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.clearCookies() // Clear cookies for the currrent domain\n```\n\n### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.clearCookies()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `domain` | Hostname of the application under test | Clears the cookies 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.clearCookies()` to resolve before [timing out](#Timeouts) |\n\n### Yields\n\n*   `cy.clearCookies()` yields `null`.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 137
    },
    {
      "id": "api/commands/clearcookies#arguments",
      "doc_id": "api/commands/clearcookies",
      "heading": "Arguments",
      "heading_level": 3,
      "content_markdown": "### Arguments\n\n**options _(Object)_**\n\nPass in an options object to change the default behavior of `cy.clearCookies()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `domain` | Hostname of the application under test | Clears the cookies 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.clearCookies()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 103
    },
    {
      "id": "api/commands/clearcookies#examples",
      "doc_id": "api/commands/clearcookies",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### No Args\n\n#### Clear cookies 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, your server sends back a session cookie on login. `cy.clearCookies()` removes that cookie, so when you visit a page that requires authentication, the server redirects you back to the login page.\n\n```\n// assume the user just logged in\ncy.contains('Login').click()\ncy.url().should('include', 'profile')\ncy.clearCookies()\ncy.visit('/dashboard') // redirected back to login\ncy.url().should('include', 'login')\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 92
    },
    {
      "id": "api/commands/clearcookies#no-args",
      "doc_id": "api/commands/clearcookies",
      "heading": "No Args",
      "heading_level": 3,
      "content_markdown": "### No Args\n\n#### Clear cookies 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, your server sends back a session cookie on login. `cy.clearCookies()` removes that cookie, so when you visit a page that requires authentication, the server redirects you back to the login page.\n\n```\n// assume the user just logged in\ncy.contains('Login').click()\ncy.url().should('include', 'profile')\ncy.clearCookies()\ncy.visit('/dashboard') // redirected back to login\ncy.url().should('include', 'login')\n```\n",
      "section": "api",
      "anchors": [
        "no-args"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 89
    },
    {
      "id": "api/commands/clearcookies#clear-cookies-after-logging-in",
      "doc_id": "api/commands/clearcookies",
      "heading": "Clear cookies after logging in[",
      "heading_level": 4,
      "content_markdown": "#### Clear cookies 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, your server sends back a session cookie on login. `cy.clearCookies()` removes that cookie, so when you visit a page that requires authentication, the server redirects you back to the login page.\n\n```\n// assume the user just logged in\ncy.contains('Login').click()\ncy.url().should('include', 'profile')\ncy.clearCookies()\ncy.visit('/dashboard') // redirected back to login\ncy.url().should('include', 'login')\n```\n",
      "section": "api",
      "anchors": [
        "clear-cookies-after-logging-in"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 85
    },
    {
      "id": "api/commands/clearcookies#notes",
      "doc_id": "api/commands/clearcookies",
      "heading": "Notes",
      "heading_level": 2,
      "content_markdown": "## Notes\n\n### Default cookie domain before visiting a page\n\nThe `domain` option defaults to the hostname of the application under test. Before [`cy.visit()`](/llm/markdown/api/commands/visit.md) loads a page, the application under test is on `about:blank`, so Cypress uses the hostname it serves the spec from instead (usually `localhost`). Pass `domain` explicitly to work with cookies on another domain before visiting.\n",
      "section": "api",
      "anchors": [
        "notes"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 79
    },
    {
      "id": "api/commands/clearcookies#default-cookie-domain-before-visiting-a-page",
      "doc_id": "api/commands/clearcookies",
      "heading": "Default cookie domain before visiting a page",
      "heading_level": 3,
      "content_markdown": "### Default cookie domain before visiting a page\n\nThe `domain` option defaults to the hostname of the application under test. Before [`cy.visit()`](/llm/markdown/api/commands/visit.md) loads a page, the application under test is on `about:blank`, so Cypress uses the hostname it serves the spec from instead (usually `localhost`). Pass `domain` explicitly to work with cookies on another domain before visiting.\n",
      "section": "api",
      "anchors": [
        "default-cookie-domain-before-visiting-a-page"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 76
    },
    {
      "id": "api/commands/clearcookies#rules",
      "doc_id": "api/commands/clearcookies",
      "heading": "Rules",
      "heading_level": 2,
      "content_markdown": "## Rules\n\n### Requirements\n\n*   `cy.clearCookies()` requires being chained off of `cy`.\n\n### Assertions\n\n*   `cy.clearCookies()` yields `null`, so there's nothing to assert on. To confirm the cookies are cleared, assert on [`cy.getCookies()`](/llm/markdown/api/commands/getcookies.md) afterward, for example `cy.getCookies().should('be.empty')`.\n\n### Timeouts\n\n*   `cy.clearCookies()` can time out waiting for the browser to clear the cookies. It waits up to the [`responseTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) (or the `timeout` option, when passed) before failing.\n*   If the application under test is on a different origin, `cy.clearCookies()` retries for up to the [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) (or the `timeout` option, when passed) and then fails with a cross-origin error. Run it inside [`cy.origin()`](/llm/markdown/api/commands/origin.md) to work with cookies on that origin.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 144
    },
    {
      "id": "api/commands/clearcookies#timeouts",
      "doc_id": "api/commands/clearcookies",
      "heading": "Timeouts",
      "heading_level": 3,
      "content_markdown": "### Timeouts\n\n*   `cy.clearCookies()` can time out waiting for the browser to clear the cookies. It waits up to the [`responseTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) (or the `timeout` option, when passed) before failing.\n*   If the application under test is on a different origin, `cy.clearCookies()` retries for up to the [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) (or the `timeout` option, when passed) and then fails with a cross-origin error. Run it inside [`cy.origin()`](/llm/markdown/api/commands/origin.md) to work with cookies on that origin.\n",
      "section": "api",
      "anchors": [
        "timeouts"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 95
    },
    {
      "id": "api/commands/clearcookies#command-log",
      "doc_id": "api/commands/clearcookies",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Clear cookies after getting cookies_**\n\n```\ncy.getCookies().should('have.length', 1)\ncy.clearCookies()\ncy.getCookies().should('be.empty')\n```\n\nThe commands above display in the Command Log as:\n\nWhen clicking on `clearCookies` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/clearcookies.json",
      "token_estimate": 48
    }
  ]
}