{
  "doc": {
    "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": "/llm/markdown/api/commands/getcookies.md",
    "version": "3cf5b86b3403f604bdf7f3e35025c3bc3865e02c",
    "updated_at": "2026-05-07T17:44:31.931Z",
    "headings": [
      {
        "id": "api/commands/getcookies#getcookies",
        "text": "getCookies",
        "level": 1
      },
      {
        "id": "api/commands/getcookies#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/getcookies#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/getcookies#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/getcookies#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/getcookies#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/getcookies#get-cookies",
        "text": "Get Cookies",
        "level": 3
      },
      {
        "id": "api/commands/getcookies#get-cookies-after-logging-in",
        "text": "Get cookies after logging in",
        "level": 4
      },
      {
        "id": "api/commands/getcookies#rules",
        "text": "Rules",
        "level": 2
      },
      {
        "id": "api/commands/getcookies#requirements-learn-about-chaining-commands",
        "text": "Requirements Learn about chaining commands",
        "level": 3
      },
      {
        "id": "api/commands/getcookies#assertions-learn-about-assertions",
        "text": "Assertions Learn about assertions",
        "level": 3
      },
      {
        "id": "api/commands/getcookies#timeouts-learn-about-timeouts",
        "text": "Timeouts Learn about timeouts",
        "level": 3
      },
      {
        "id": "api/commands/getcookies#command-log",
        "text": "Command Log",
        "level": 2
      },
      {
        "id": "api/commands/getcookies#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/getcookies#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/commands/getcookies#syntax",
      "doc_id": "api/commands/getcookies",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\ncy.getCookies()cy.getCookies(options)\n```\n\n### Usage\n\n**Correct Usage**\n\n```\ncy.getCookies() // Get 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.getCookies()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `domain` | Hostname of the current URL | Retrieves 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.getCookies()` 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.getCookies()` yields an array of cookie objects. Each cookie object has the following properties:\n\n*   `domain`: _(String)_\n*   `expiry`: _(Number)_ _(if specified)_\n*   `hostOnly`: _(Boolean)_ _(if specified)_\n*   `httpOnly`: _(Boolean)_\n*   `name`: _(String)_\n*   `path`: _(String)_\n*   `sameSite`: _(String)_ _(if specified)_\n*   `secure`: _(Boolean)_\n*   `value`: _(String)_\n\n`cy.getCookies()` is not a query. It will not update the returned list if further cookies are added after it initially executes.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 225
    },
    {
      "id": "api/commands/getcookies#arguments",
      "doc_id": "api/commands/getcookies",
      "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.getCookies()`.\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `domain` | Hostname of the current URL | Retrieves 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.getCookies()` to resolve before [timing out](#Timeouts) |\n",
      "section": "api",
      "anchors": [
        "arguments"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 101
    },
    {
      "id": "api/commands/getcookies#yields-learn-about-subject-management",
      "doc_id": "api/commands/getcookies",
      "heading": "Yields Learn about subject management",
      "heading_level": 3,
      "content_markdown": "### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)\n\n`cy.getCookies()` yields an array of cookie objects. Each cookie object has the following properties:\n\n*   `domain`: _(String)_\n*   `expiry`: _(Number)_ _(if specified)_\n*   `hostOnly`: _(Boolean)_ _(if specified)_\n*   `httpOnly`: _(Boolean)_\n*   `name`: _(String)_\n*   `path`: _(String)_\n*   `sameSite`: _(String)_ _(if specified)_\n*   `secure`: _(Boolean)_\n*   `value`: _(String)_\n\n`cy.getCookies()` is not a query. It will not update the returned list if further cookies are added after it initially executes.\n",
      "section": "api",
      "anchors": [
        "yields-learn-about-subject-management"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 99
    },
    {
      "id": "api/commands/getcookies#examples",
      "doc_id": "api/commands/getcookies",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Get Cookies\n\n#### Get cookies after logging in\n\nIn this example, on first login our server sends us back a session cookie.\n\n```\n// 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')  })\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 56
    },
    {
      "id": "api/commands/getcookies#get-cookies",
      "doc_id": "api/commands/getcookies",
      "heading": "Get Cookies",
      "heading_level": 3,
      "content_markdown": "### Get Cookies\n\n#### Get cookies after logging in\n\nIn this example, on first login our server sends us back a session cookie.\n\n```\n// 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')  })\n```\n",
      "section": "api",
      "anchors": [
        "get-cookies"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 53
    },
    {
      "id": "api/commands/getcookies#get-cookies-after-logging-in",
      "doc_id": "api/commands/getcookies",
      "heading": "Get cookies after logging in",
      "heading_level": 4,
      "content_markdown": "#### Get cookies after logging in\n\nIn this example, on first login our server sends us back a session cookie.\n\n```\n// 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')  })\n```\n",
      "section": "api",
      "anchors": [
        "get-cookies-after-logging-in"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 49
    },
    {
      "id": "api/commands/getcookies#rules",
      "doc_id": "api/commands/getcookies",
      "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.getCookies()` 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.getCookies()` will only run assertions you have chained once, and will not [retry](/llm/markdown/app/core-concepts/retry-ability.md).\n\n### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)\n\n*   `cy.getCookies()` should never time out.\n\nBecause `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.\n",
      "section": "api",
      "anchors": [
        "rules"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 101
    },
    {
      "id": "api/commands/getcookies#timeouts-learn-about-timeouts",
      "doc_id": "api/commands/getcookies",
      "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.getCookies()` should never time out.\n\nBecause `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.\n",
      "section": "api",
      "anchors": [
        "timeouts-learn-about-timeouts"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 55
    },
    {
      "id": "api/commands/getcookies#command-log",
      "doc_id": "api/commands/getcookies",
      "heading": "Command Log",
      "heading_level": 2,
      "content_markdown": "## Command Log\n\n**_Get browser cookies and inspect all properties_**\n\n```\ncy.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')  })\n```\n\nThe commands above will display in the Command Log as:\n\nWhen clicking on `getCookies` within the command log, the console outputs the following:\n",
      "section": "api",
      "anchors": [
        "command-log"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 67
    },
    {
      "id": "api/commands/getcookies#history",
      "doc_id": "api/commands/getcookies",
      "heading": "History",
      "heading_level": 2,
      "content_markdown": "## History\n\n| Version | Changes |\n| --- | --- |\n| [5.0.0](/llm/markdown/app/references/changelog.md#5-0-0) | Removed `experimentalGetCookiesSameSite` and made `sameSite` property always available. |\n| [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`. |\n",
      "section": "api",
      "anchors": [
        "history"
      ],
      "path": "/llm/json/chunked/api/commands/getcookies.json",
      "token_estimate": 51
    }
  ]
}