> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Hydrating sessions

> Hydrate the frontend session state from the backend.

## Use case

* **Backend-initiated session changes:** Ensure your frontend session state stays in sync when sessions are created or updated on the backend.

***

## Session hydration

<Steps>
  <Step title="Update session tokens">
    Provide both the active `session_token` and `session_jwt` to the `session.updateSession()` [method](/api-reference/b2b/frontend-sdks/react/methods/sessions/update-session) to prime the frontend with a valid set of tokens.
  </Step>

  <Step title="Make an authenticate session call">
    Authenticate the session using the `session.authenticate()` [method](/api-reference/b2b/frontend-sdks/react/methods/sessions/authenticate-session) to validate the updated session tokens.
  </Step>

  <Step title="Example" icon="code">
    ```javascript lines theme={null}
    export const hydrateSession = () => {
        stytch.session.updateSession({
            session_token: 'ACTIVE_SESSION_TOKEN',
            session_jwt: 'ACTIVE_SESSION_JWT',
        });

        stytch.session.authenticate();
    };
    ```
  </Step>
</Steps>

<Note>
  When `HttpOnly` cookies are enabled for your Stytch project, the [Sessions Update method](/api-reference/b2b/frontend-sdks/react/methods/sessions/update-session) only works if there isn't an existing session token set in an `HttpOnly` cookie.

  * If `HttpOnly` cookies are enabled, make sure your SDK client's `cookieOptions` are configured to match the domain and cookie names used by Stytch's backend.

  * Alternatively, you can override the session cookies via response headers from your backend. Be sure to still make a frontend authenticate session call.
</Note>
