How to store level as variable?,How to save current level as variable?

In my project I would like the current level the player is on to be stored as a variable so that it is easy to restart the level they are on when the character dies. Answers in both blueprints and c++ would be helpful.,I don’t know if this is right but in my project I would like the current level the players is on to be stored as a variable so it is easy to make the restart code. Both c++ and blueprints would be fine. I am using unreal engine 4.22.

Every asset has it class and level is ULevel. Usally you can figure name of the class by looking on asset type name in tooltip inside parenthesis

But level is usually stored as FName as UE4 use URI address to open levels and connect to server

You can store your levels as an integer variable in an “actor object” you place in each level. If you name each level (map) something like “LevelX” where “X” is a number then you can simply create an array of your level names, and use a get node with an integer for the level to select and open whatever level the player is on based on the integer variable saved to a save game object. Similar to this setup.

Blueprints:
There is a node named GetCurrentLevelName or something like that. It returns a Name you can store either as a Name or a String. You can use this same Name or String as the input for the Open Level node.

There might be a RestartLevel node on some kinds of GameMode too, which might be simpler, but I dont remember.