Skip to main content

Session

The Session object is responsible for maintaining persistent data around user sessions over the life-time of an application.

Session information is persisted using file storage on most platforms except for tvOS and WebGL. On those two platforms, session information is stored in PlayerPrefs.

Constructor

Argument NameDescriptionRequired?Default
sessionPathThe file path to store the persistent session state inYes (accepts null)"snowplow_session.dict"
foregroundTimeoutThe time until a session expires in focusNo600 (s)
backgroundTimeoutThe time until a session expires in backNo300 (s)
checkIntervalHow often to validate the session timeoutNo15 (s)

A full Session construction should look like the following:

Session session = new Session ("snowplow_session_state.json", 1200, 600, 30);

A minimal construction would be:

Session session = new Session (null);

The timeouts refer to the length of time the session remains active after the last event is sent. As long as events are sent within this limit the session will not timeout.

Functions

Except sessionPath, all of the constructor variables can be altered/retrieved after creation with the accompanying session.SetXXX()/session.GetXXX() functions.

SetBackground(bool)

Will set whether or not the application is in the background. It is up to the developer to set this metric if they wish to have a different timeout for foreground and background.