How to save client variables before joining session and load them back after joining session

Let me explain what I want to do first. I’m writing with blueprints

(1) I’m writing a 2 player fighting game which has four heroes. The player has to choose a hero first then will be loaded into a map.

(2) Server player chose the hero, hosts the game and loads into the map. Everything is ok.

(3) The client player has to choose the hero before joining the session. Then joins the session and loads into the map of server player.

(4) To store which hero is chosen by client, I stored the index of hero into a variable named P2Hero in playerState blueprint.( This step occurs before joining the session )

(5) After joining the session, and onPostLogin event, I want to get back the saved ** P2Hero** variable from client’s playerState blueprint but it seems like it is getting the variable from another playerState blueprint and just gives the default value of the variable 0.

(6) My main point is how to save datas of client before joining the session and how to load them back after joining the session.

Someone pls help me. I’m having a really big trouble. I’ve tried saving the data in gameInstance, gameMode, playerController. All of them just gives the default value like mentioned above. May be the whole logic of mine is wrong. If wrong pls point me how to solve this problem. Thanks.

Here Saving and Loading Your Game | Unreal Engine Documentation

Thank you for your advice. I think there must be another better way. But I’m current using your advice and it works. Thanks.

Did you ever find a “proper way” to do this? I’m having the exact same problem.

I am facing the same problem, as well.

If steam “advanced session plugin” and use unique steam ID. If non-steam, generate random int on server, send those to clients to store and on login compare the int on server stored one to find which player is which.

Using Savegame slot was very simple and effective. It’s my opinion that it is a “proper” way to do this, and there may be many “proper” ways. As a bonus, the data persists between closing the game and starting it up again (from the client perspective of course)

gi works fine, add delay to the postlogin pc event