Handle Returning Users

We don't want a player to have to type in their email and password every time they start the game, so for this we can reuse the session token provided by the WhiteLabelLogin call multiple times.

By default a session token is good for 24 hours, but if you send remember me to true a session will last for 30 days. Remember that these sessions are disconnected from the game session, so you still want to create a game session every time the player opens your game.

The length of a remember session can be changed in platform settings for White Label Login.

When a player opens the game we first want to check if they have a previous session we can use:

// Remember to use the LootLocker namespace in the top of your file.
using LootLocker.Requests;

LootLockerSDKManager.CheckWhiteLabelSession(response =>
{
    if (response)
    {
        // Start a new session
        Debug.Log("session is valid, you can start a game session");
    }
    else
    {
        // Show login form here
        Debug.Log("session is NOT valid, we should show the login form");
    }
});

Depending on the response from this code we can either show the login form and ask for email and password again or we can start a game session.

Request Password Reset

If the user wants to reset their password we can use the following example to send them an email with a link to a reset password page.

The page is hosted on LootLocker and will use the settings in Platform Settings for name and logo.

// Remember to use the LootLocker namespace in the top of your file.
using LootLocker.Requests;

// This code should be placed in a handler when user clicks reset password.
string email = "user@lootlocker.io";
LootLockerSDKManager.WhiteLabelRequestPassword(email, (response) =>
{
    if (!response.success)
    {
        Debug.Log("error requesting password reset");

        return;
    }

    Debug.Log("requested password reset successfully");
});

Last updated