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

# Get Session

> Retrieve session details using the Stytch React SDK

> [!NOTE]
>
> In React, use the [`useStytchSession`](../../hooks/use-stytch-session) hook to access the active Session and react to changes.

The Stytch SDK caches the Session of the logged-in User (Represents an end user's account in your application.). `session.getSync` is a synchronous method that fetches the cached Session object.

If there is no cached data, this method returns `null`.

The `session.getInfo` method is similar to `session.getSync`, but returns an object containing the `session` object and a `fromCache` boolean. If `fromCache` is true, the session object is from the cache and a state refresh is in progress.

You can listen for changes with the `session.onChange` method, which invokes your callback whenever the Session object changes.

## Response

**session\_id** `string`

A unique identifier for a specific Session.

**user\_id** `string`

The unique ID of the affected User.

**authentication\_factors** `array[objects]`

An array of different authentication factors that comprise a Session.

**started\_at** `string`

The timestamp when the Session was created. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

**last\_accessed\_at** `string`

The timestamp when the Session was last accessed. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

**expires\_at** `string`

The timestamp when the Session expires. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.

**attributes** `object`

Provided attributes help with fraud detection.

**properties**

**ip\_address** `string`

The IP address of the user.

**user\_agent** `string`

The user agent of the User.

**custom\_claims** `map`

The custom claims map for a Session. Claims can be added to a session during a Sessions authenticate call.

**roles** `array[string]`

A list of the roles associated with the session.

```jsx theme={null}
import { useStytch } from '@stytch/react';

export const SessionDisplay = () => {
  const stytch = useStytch();
  const session = stytch.session.getSync();

  return session ? (
    <p>Session ID: {session.session_id}</p>
  ) : (
    <p>No active session</p>
  );
};
```
