Skip to main content

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

1

Update session tokens

Provide both the active session_token and session_jwt to the session.updateSession() method to prime the frontend with a valid set of tokens.
2

Make an authenticate session call

Authenticate the session using the session.authenticate() method to validate the updated session tokens.

Example

When HttpOnly cookies are enabled for your Stytch project, the Sessions Update method 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.