# Guest Login

{% hint style="info" %}
If you're not using any specific first party platform or just want something simple, you can use our Guest Login feature to create player sessions.
{% endhint %}

Guest Login provides the player with a simple reusable session which supports most of LootLocker's features, with the exception of platform specific features such as payments through Steam etc.

#### Register a Session

{% tabs %}
{% tab title="Unity" %}
{% hint style="warning" %}
This requires that you have [set up the Unity SDK in your game.](../../../the-basics/unity-quick-start)
{% endhint %}

We'll start by creating a new empty Game Object in your scene and calling it GameManager. Feel free to skip this if you already have a GameManager or similar in your game.

![](https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-4e090a11374e7a13449de3fd27a65d56c8e2bdf8%2Fcreate_empty_game_object.png?alt=media)

Then in this new GameObject you can add a new script called GameManager

![](https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-e97c45c6d0c253c31500167cc0cb8aad51013a44%2Fadd-game-manager-script.png?alt=media)

Open up your new script in your editor of choice and add the following code.

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LootLocker.Requests;

public class GameManager : MonoBehaviour
{
    void Start()
    {
        LootLockerSDKManager.StartGuestSession((response) =>
        {
            if (!response.success)
            {
                Debug.Log("error starting LootLocker session");

                return;
            }

            Debug.Log("successfully started LootLocker session");
        });
    }
}
```

To confirm that everything is running without errors, you can start your game and check the console for the correct Debug.Log message.
{% endtab %}

{% tab title="Unreal" %}
{% hint style="warning" %}
This requires that you have [set up the Unreal SDK in your game.](../../../the-basics/unreal-quick-start)
{% endhint %}

<figure><img src="https://534367586-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MVu1MPzezO-NgvC98xh%2Fuploads%2Fgit-blob-9f96332bbdf90cfdd3cb69467a9ad10b234dc86c%2FGuestLogin.png?alt=media" alt="Shows an example of how to implement guest login in Unreal Blueprints - see link: https://blueprintue.com/blueprint/chv8-bf-/"><figcaption><p><a href="https://blueprintue.com/blueprint/chv8-bf-/">Blueprint example of guest login</a></p></figcaption></figure>

Above is an example of how to implement Guest Login using blueprints in Unreal Engine. For an example you can copy and paste into your editor, [look here](https://blueprintue.com/blueprint/chv8-bf-/).

**Input**

You need to exchange the `TriggerGuestLogin` event for whatever event you want to use to trigger the login flow. For Guest Login without a specific identifier you could, for example, trigger it on the `BeginPlay` event.

Remove the node "Optional: Set Player Identifier". The `Guest Login` node can take a Player Identifier input, and if you supply one the player will be logged in with that identifier. Note however that this needs to be unique for each player and there is no authentication tied to the identifier. If you do not input a player identifier a unique one will be generated for you and remembered between game starts.

**Output**

For subsequent calls to different LootLocker methods you will want to create variables from the Player Id and Player Identifier outputs.

We recommend branching the completed events on the success flag, and if you do this you will probably want to add error handling in case the request fails.
{% endtab %}

{% tab title="Godot" %}
{% hint style="warning" %}
This requires that you have [set up the Godot SDK in your game.](../../../the-basics/godot-quick-start)
{% endhint %}

Open up the script from which you want to trigger LootLocker Authentication in Godot and add the following code:

```gdscript

var guestLoginResponse = await LL_Authentication.GuestSession.new(playerIdentifier).send()
if(!guestLoginResponse.success) :
  printerr("Guest login failed with reason: " + guestLoginResponse.error_data.to_string())
  return

print("Guest user was successfully signed in to LootLocker")
```

To confirm that everything is running without errors, you can start your game and check the console for the correct message in the log.
{% endtab %}

{% tab title="REST" %}
Register a new player:

<pre class="language-bash"><code class="lang-bash"><strong>curl -X POST "https://api.lootlocker.io/game/v2/session/guest" \
</strong>  -H "Content-Type: application/json" \
  -d "{\"game_key\": \"your_game_key\", \"game_version\": \"0.10.0.0\"}"
</code></pre>

Register an existing player:

```bash
curl -X POST "https://api.lootlocker.io/game/v2/session/guest" \
  -H "Content-Type: application/json" \
  -d "{\"game_key\": \"your_game_key\", \"player_identifier\": \"ec9b35e6-b184-4f34-b49f-980f86b291e2\", \"game_version\": \"0.10.0.0\"}"
```

Example response:

```json
{
  "success": true,
  "session_token": "e6fa44946f077dd9fe67311ab3f188c596df9969",
  "player_id": 3,
  "public_uid": "TSEYDXD8",
  "player_identifier": "ec9b35e6-b184-4f34-b49f-980f86b291e2",
  "player_created_at": "2022-05-30T07:56:01+00:00",
  "check_grant_notifications": true,
  "check_deactivation_notifications": false,
  "seen_before": true
}
```
{% endtab %}
{% endtabs %}

{% hint style="success" %}
Congratulations - you have now started using LootLocker in your game with Guest Login! Next up we suggest you look at our [feature set](../../../../the-basics/what-is-lootlocker#overview), and decide which ones you want to use in your game.
{% endhint %}
