# Sessions

Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fsdk-installation%2Froku%2Ffeatures%2Fsessions.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Frum%2Fsdk-installation%2Froku%2Ffeatures%2Fsessions.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

A session groups everything one viewer does in one sitting. This page covers when a session ends, how to hold one open through video playback, and how to start a new one deliberately.

### When a session ends[​](#when-a-session-ends "Direct link to When a session ends")

A session starts at `coralogix_roku_initialize()` and ends after either of these:

| Ends after                                                                                                 | What extends it                                    |
| ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| 2 hours of inactivity. Change this setting to 15-240 minutes with `sessionConfig.inactivityTimeoutMinutes` | A key press on the remote, or `reportUserActivity` |
| 4 hours in total                                                                                           | Can't be extended.                                 |

The next record after a session ends starts a new session instead of being dropped. The new session links to the one before it through `prev_session`. Each new session is sampled again, so with a `sessionSampleRate` below 100 it may not be recorded. An `inactivityTimeoutMinutes` of `240` matches the 4-hour limit, so in practice only that limit ends a session.

### Keep the session alive during playback[​](#keep-the-session-alive-during-playback "Direct link to Keep the session alive during playback")

Video playback produces no key presses, so a long video watched without pressing any key ends the current session part-way through, after 2 hours. To keep one session for the whole video, call [`reportUserActivity`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#reportuseractivity) while content plays, for example from your `Video` node's `position` observer:

```
sub onPositionChange()

    m.global.cxRum.callfunc("reportUserActivity")

end sub
```

The call refreshes the idle timer only, so calling it on every position update is fine. It does not extend the four-hour total limit. When the session has already ended, the call starts a new one and returns the new session ID.

To read the current session ID without affecting the session, use [`getSessionId`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#getsessionid) instead.

### Start a new session[​](#start-a-new-session "Direct link to Start a new session")

To end the current session and start a new one, for example when the viewer signs out or switches profile, call [`createNewSession`](https://coralogix.com/docs/user-guides/rum/sdk-installation/roku/features/api-reference.md#createnewsession):

```
newSessionId = m.global.cxRum.callfunc("createNewSession")
```

Records sent after this call belong to the new session.
