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

# Session rules

> Limit how long a session can run and how long viewers can sit idle.

Configure from **Project Settings → Session Rules**. These limits apply to **every** viewer of your project — regardless of whether they connect via the share link, an iframe, or the Web SDK.

<iframe width="100%" height="420" src="https://www.youtube.com/embed/LcT9zGNRVLY" title="Max Runtime & Inactivity Timeout" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowfullscreen />

## Max runtime

How long a single session can stay connected before being disconnected automatically.

| Property | Value                           |
| -------- | ------------------------------- |
| Default  | 30 minutes                      |
| Range    | 1 – 1440 minutes (24 hours max) |

When a session hits the limit, the viewer is disconnected with code `4004` (max runtime reached). Use this to prevent forgotten tabs from holding a worker indefinitely.

## Inactivity timeout (AFK)

How long a viewer can go without input before being disconnected.

| Property | Value                          |
| -------- | ------------------------------ |
| Default  | 300 seconds (5 minutes)        |
| Range    | 1 – 7200 seconds (2 hours max) |

Inactivity is measured from the last input event (mouse, keyboard, touch, gamepad). When the timeout fires, the viewer is disconnected — freeing the worker for the next person in queue.

<Tip>
  Set the inactivity timeout aggressively if your CCU is constrained. An idle viewer holds a full GPU worker.
</Tip>

## Auto-delete cache

A toggle in the same Session Rules tab. When on, locally cached application data is cleared at the end of every session. Use it for privacy-sensitive deployments (configurators with customer data, kiosk demos, internal tools) where you don't want the next viewer to inherit anything.

## Where these rules apply

These are project-level settings stored on Streampixel. You don't need to set them again in your iframe or SDK code — they're enforced server-side, on every session, no matter how the viewer connected.

The Web SDK does expose hooks ([AFK / idle timeout](/resources/web-sdk/features/afk-idle-timeout)) so you can show a custom warning UI before the disconnect, but the underlying timeout is the one set here.

## Next

<CardGroup cols={2}>
  <Card title="Disconnect codes" icon="plug-circle-xmark" href="/resources/quick-start-guide/disconnect-codes">
    What `4004` and other codes mean.
  </Card>

  <Card title="AFK timeout in the SDK" icon="code" href="/resources/web-sdk/features/afk-idle-timeout">
    Hook into idle/disconnect events for a custom UI.
  </Card>
</CardGroup>
