Skip to main content

Managing Sessions

The k-ID Session contains the collection of permissions and age status for the current player and location. Every player requires an active Session. The game should consult the active Session to determine whether features are enabled or disabled in the game.

A k-ID Session does not automatically expire. It is designed to be cached in local storage or cloud storage associated with the player. For kids and teens, the Session can change either if a parent adds or removes permissions using the Family Portal, or the player has a birthday and "ages up" to a new age category in the juridication where the session was established. Since the Session is designed to be cached, it should be refreshed using the /session/get API every time the game starts to get any changes that have been made.

Getting the session with a session ID in Unreal C++
// read the session from the API into a member variable named SessionInfo
void UKidWorkflow::GetSessionPermissions(const FString& SessionId, const FString& ETag)
{
FString Url = FString::Printf(TEXT("%s/session/get?sessionId=%s&etag=%s"), *BaseUrl,
*SessionId, *ETag);


HttpRequestHelper::GetRequestWithAuth(Url, AuthToken,
[this](FHttpResponsePtr Response, bool bWasSuccessful)
{
if (bWasSuccessful && Response.IsValid())
{
if (Response->GetResponseCode() == 304)
{
UE_LOG(LogTemp, Log, TEXT("Session information is up-to-date."));
return;
}


TSharedRef<TJsonReader<>> Reader =
TJsonReaderFactory<>::Create(Response->GetContentAsString());
if (FJsonSerializer::Deserialize(Reader, SessionInfo))
{
// Save the member variable SessionInfo to local or cloud storage...
SaveSessionInfo();
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("/session/get failed"));
}
});
}
example session
{
"session": {
"ageStatus": "LEGAL_ADULT",
"dateOfBirth": "2005-04-15",
"etag": "6d9d24fccd428f845b355122799948dd0a52fc5d",
"jurisdiction": "US-CA",
"permissions": [
{
"enabled": true,
"managedBy": "PLAYER",
"name": "ai-generated-avatars"
},
{
"enabled": true,
"managedBy": "PLAYER",
"name": "text-chat-private"
}
],
"sessionId": "608616da-4fd2-4742-82bf-ec1d4ffd8187",
"status": "ACTIVE"
},
"status": "PASS"
}