# Update player data

> Modify player-scoped custom data within a session to track individual player states and preferences.

Players can update their own data in a session. The session host and other players can read this data depending on the data visibility option. Refer to [Lobby data and player data](./session-data-and-player-data.md#data-access-and-visibility) for more information in available data types.

The following code sample shows how to update player data:

*C#*

```cs
using Unity.Services.Multiplayer;
using System.Collections.Generic;
using UnityEngine;

// ...

try
{
    // Assume 'session' is an active ISession instance the player has joined.

    // 1. Define the custom player data 
    // Visibility options include Public, Member, and Private.
    var properties = new Dictionary<string, PlayerProperty>
    {
        {
            "existing data key", new PlayerProperty(
                visibility: VisibilityOptions.Private,
                value: "updated data value")
        },
        {
            "new data key", new PlayerProperty(
                visibility: VisibilityOptions.Public,
                value: "new data value")
        }
    };

    // 2. Assign the properties to the current player
    // This automatically associates the data with your authenticated player ID.
    session.CurrentPlayer.SetProperties(properties);

    // 3. Commit the changes to the backend
    await session.SaveCurrentPlayerDataAsync();

    //...
}
catch (SessionException e)
{
    // Multiplayer Services uses SessionException for API errors.
    Debug.Log(e);
}
```
