---
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: docs/api/cypress-api/session.mdx
version: ce02913654e2655ee63448bdc92bb92c7b46a619
updated_at: '2026-04-22T19:37:51.587Z'
---
# Cypress.session

`Cypress.session` is a collection of async session-related helper methods
intended to be used alongside the [`cy.session()`](/llm/markdown/api/commands/session.md)
command.

## Syntax

```javascript
// 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)
```

Clearing 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).

### Arguments

 **id *(String)***

The name of the session used to retrieve data storage and cookie data.

## Examples

### Clearing the all session data

By 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()`.

```js
Cypress.session.clearAllSavedSessions()
```

### Clearing the current session data when testIsolation is disabled

By 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.

```js
describe('Dashboard', { testIsolation: false }, () => {
  before(() => {
    // ensure clean test slate for these tests
    cy.then(Cypress.session.clearCurrentSessionData)
  })
})
```

### Verified the Applied Session Data

To 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.

Since 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.

```js
it('debug session', () => {
    cy.session('id', () => {
        ...
    })
    .then(async () => {
        const sessionData = await Cypress.session.getCurrentSessionData()
        cy.debug()
    })
})
```

### Debugging Cached Session Data

If 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.

```js
it('debug session', () => {
    cy.session('id', () => {
        ...
    })
    .then(async () => {
        const sessionData = await Cypress.session.getSession('id')
        cy.debug()
    })
})
```

## See also

- [`cy.session()`](/llm/markdown/api/commands/session.md)
