{
  "doc": {
    "id": "api/cypress-api/session",
    "title": "Cypress.session | Cypress Documentation",
    "description": "A collection of async session-related helper methods intended to be used alongside the cy.session() command.",
    "section": "api",
    "source_path": "/llm/markdown/api/cypress-api/session.md",
    "version": "a8fd16711bdda4c7b5645b9717e588ae99ec2470",
    "updated_at": "2026-05-18T17:21:32.047Z",
    "headings": [
      {
        "id": "api/cypress-api/session#cypress-session",
        "text": "Cypress.session",
        "level": 1
      },
      {
        "id": "api/cypress-api/session#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/cypress-api/session#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/cypress-api/session#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/cypress-api/session#clearing-the-all-session-data",
        "text": "Clearing the all session data",
        "level": 3
      },
      {
        "id": "api/cypress-api/session#clearing-the-current-session-data-when-testisolation-is-disabled",
        "text": "Clearing the current session data when testIsolation is disabled",
        "level": 3
      },
      {
        "id": "api/cypress-api/session#verified-the-applied-session-data",
        "text": "Verified the Applied Session Data",
        "level": 3
      },
      {
        "id": "api/cypress-api/session#debugging-cached-session-data",
        "text": "Debugging Cached Session Data",
        "level": 3
      },
      {
        "id": "api/cypress-api/session#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "chunks": [
    {
      "id": "api/cypress-api/session#syntax",
      "doc_id": "api/cypress-api/session",
      "heading": "Syntax",
      "heading_level": 2,
      "content_markdown": "## Syntax\n\n```\n// Clear all sessions saved on the backend, including cached global sessions.Cypress.session.clearAllSavedSessions()// Clear all storage and cookie date across all origins associated with the current session.Cypress.session.clearCurrentSessionData()// Get all storage and cookie data across all origins associated with the current session.Cypress.session.getCurrentSessionData()// Get all storage and cookie data saved on the backend associated with the provided session id.Cypress.session.getSession(id)\n```\n\nClearing all session and automatically re-running the spec `Cypress.session.clearAllSavedSessions()` can also be done by clicking the \"Clear All Sessions\" button in the [Sessions Instrument Panel](/llm/markdown/api/commands/session.md#The-Instrument-Panel).\n\n### Arguments\n\n**id _(String)_**\n\nThe name of the session used to retrieve data storage and cookie data.\n",
      "section": "api",
      "anchors": [
        "syntax"
      ],
      "path": "/llm/json/chunked/api/cypress-api/session.json",
      "token_estimate": 136
    },
    {
      "id": "api/cypress-api/session#examples",
      "doc_id": "api/cypress-api/session",
      "heading": "Examples",
      "heading_level": 2,
      "content_markdown": "## Examples\n\n### Clearing the all session data\n\nBy default, Cypress will clear the current session data **before** each test when `testIsolation` is enabled. You can also remove all cached session data with `Cypress.session.clearAllSavedSessions()`.\n\n```\nCypress.session.clearAllSavedSessions()\n```\n\n### Clearing the current session data when testIsolation is disabled\n\nBy default, Cypress will clear the current session data **before** each test when `testIsolation` is enabled. If you have disabled `testIsolation` for a suite, it can be helpful to clear the current session data in a `before()` block to ensure the suite started in a clean test slate.\n\n```\ndescribe('Dashboard', { testIsolation: false }, () => {  before(() => {    // ensure clean test slate for these tests    cy.then(Cypress.session.clearCurrentSessionData)  })})\n```\n\n### Verified the Applied Session Data\n\nTo check all cookies, localStorage and sessionStorage that was applied after `cy.session()` completes, you can use `Cypress.session.getCurrentSessionData()`. This can be helpful for quickly analyzing the current browser context while writing your `cy.session()` command.\n\nSince this is an all-in-one helper of the `cy.getAllCookies()`, `cy.getAllLocalStorage()` and `cy.getAllSessionStorage()` commands, we generally recommend leveraging these commands for asserting the correct session data has been applied in the session validation block.\n\n```\nit('debug session', () => {    cy.session('id', () => {        ...    })    .then(async () => {        const sessionData = await Cypress.session.getCurrentSessionData()        cy.debug()    })})\n```\n\n### Debugging Cached Session Data\n\nIf your session seems to be recreated more than expected, or doesn't seem to be applying the cookies, `localStorage` or `sessionStorage` data that you'd expect, you can use `Cypress.session.getSession(id)` to view what session data has been cached by `cy.session()`. If you are missing any data, your setup and/or validate function may not be waiting long enough for all attributes to be applied to there page before the `cy.session()` command saves and finishes.\n\n```\nit('debug session', () => {    cy.session('id', () => {        ...    })    .then(async () => {        const sessionData = await Cypress.session.getSession('id')        cy.debug()    })})\n```\n",
      "section": "api",
      "anchors": [
        "examples"
      ],
      "path": "/llm/json/chunked/api/cypress-api/session.json",
      "token_estimate": 420
    },
    {
      "id": "api/cypress-api/session#clearing-the-all-session-data",
      "doc_id": "api/cypress-api/session",
      "heading": "Clearing the all session data",
      "heading_level": 3,
      "content_markdown": "### Clearing the all session data\n\nBy default, Cypress will clear the current session data **before** each test when `testIsolation` is enabled. You can also remove all cached session data with `Cypress.session.clearAllSavedSessions()`.\n\n```\nCypress.session.clearAllSavedSessions()\n```\n",
      "section": "api",
      "anchors": [
        "clearing-the-all-session-data"
      ],
      "path": "/llm/json/chunked/api/cypress-api/session.json",
      "token_estimate": 47
    },
    {
      "id": "api/cypress-api/session#clearing-the-current-session-data-when-testisolation-is-disabled",
      "doc_id": "api/cypress-api/session",
      "heading": "Clearing the current session data when testIsolation is disabled",
      "heading_level": 3,
      "content_markdown": "### Clearing the current session data when testIsolation is disabled\n\nBy default, Cypress will clear the current session data **before** each test when `testIsolation` is enabled. If you have disabled `testIsolation` for a suite, it can be helpful to clear the current session data in a `before()` block to ensure the suite started in a clean test slate.\n\n```\ndescribe('Dashboard', { testIsolation: false }, () => {  before(() => {    // ensure clean test slate for these tests    cy.then(Cypress.session.clearCurrentSessionData)  })})\n```\n",
      "section": "api",
      "anchors": [
        "clearing-the-current-session-data-when-testisolation-is-disabled"
      ],
      "path": "/llm/json/chunked/api/cypress-api/session.json",
      "token_estimate": 108
    },
    {
      "id": "api/cypress-api/session#verified-the-applied-session-data",
      "doc_id": "api/cypress-api/session",
      "heading": "Verified the Applied Session Data",
      "heading_level": 3,
      "content_markdown": "### Verified the Applied Session Data\n\nTo check all cookies, localStorage and sessionStorage that was applied after `cy.session()` completes, you can use `Cypress.session.getCurrentSessionData()`. This can be helpful for quickly analyzing the current browser context while writing your `cy.session()` command.\n\nSince this is an all-in-one helper of the `cy.getAllCookies()`, `cy.getAllLocalStorage()` and `cy.getAllSessionStorage()` commands, we generally recommend leveraging these commands for asserting the correct session data has been applied in the session validation block.\n\n```\nit('debug session', () => {    cy.session('id', () => {        ...    })    .then(async () => {        const sessionData = await Cypress.session.getCurrentSessionData()        cy.debug()    })})\n```\n",
      "section": "api",
      "anchors": [
        "verified-the-applied-session-data"
      ],
      "path": "/llm/json/chunked/api/cypress-api/session.json",
      "token_estimate": 128
    },
    {
      "id": "api/cypress-api/session#debugging-cached-session-data",
      "doc_id": "api/cypress-api/session",
      "heading": "Debugging Cached Session Data",
      "heading_level": 3,
      "content_markdown": "### Debugging Cached Session Data\n\nIf your session seems to be recreated more than expected, or doesn't seem to be applying the cookies, `localStorage` or `sessionStorage` data that you'd expect, you can use `Cypress.session.getSession(id)` to view what session data has been cached by `cy.session()`. If you are missing any data, your setup and/or validate function may not be waiting long enough for all attributes to be applied to there page before the `cy.session()` command saves and finishes.\n\n```\nit('debug session', () => {    cy.session('id', () => {        ...    })    .then(async () => {        const sessionData = await Cypress.session.getSession('id')        cy.debug()    })})\n```\n",
      "section": "api",
      "anchors": [
        "debugging-cached-session-data"
      ],
      "path": "/llm/json/chunked/api/cypress-api/session.json",
      "token_estimate": 135
    }
  ]
}