Unreal Engine 5 · Blueprint → C++
Event OnLogout in Unreal Engine 5 C++ (Logout)
The Blueprint Event OnLogout node maps to overriding the virtual Logout(AController* Exiting) function on your AGameModeBase subclass in Unreal Engine 5 C++.
Blueprint node & C++ equivalent

public:
// This method gets called every time a user logs out
virtual void Logout(AController* Exiting) override;void ExampleGameMode::Logout(AController* Exiting)
{
// Your code here...
}What does the OnLogout node do?
Event OnLogout fires on the server when a player leaves the game, whether they disconnect, are kicked, or quit. It is the place to clean up that player's data: remove them from team lists, save progress, or notify other players. The Exiting pin is the controller for the player who is leaving.
The C++ equivalent
Override the virtual Logout function from AGameModeBase. Declare virtual void Logout(AController* Exiting) override; in your .h file and implement it in the .cpp. Note the parameter type is AController*, not APlayerController*, because logout can apply to any controller, including AI controllers, so handle the case where a cast to APlayerController may fail.
If you want the engine's default logout behavior to run as well, call Super::Logout(Exiting) inside your override; the example body is left for your custom cleanup code.
When to use it
Use the Logout override whenever you need authoritative cleanup at the moment a player exits. Because it runs on the server, it is reliable for saving state or updating the game mode's player count. Pair it with PostLogin so every join has a matching teardown path.
Frequently asked questions
What is the C++ equivalent of Event OnLogout in UE5?+
Override the virtual function void Logout(AController* Exiting) on your AGameModeBase subclass to run code when a player leaves.
Why is the Logout parameter AController instead of APlayerController?+
Logout can be triggered for any controller leaving the game, including AI controllers, so the signature uses the more general AController*. Cast to APlayerController only after a null-checked cast.
Should I call Super::Logout?+
Call Super::Logout(Exiting) if you want the engine's default logout handling to run alongside your cleanup; place your custom code around it as needed.