# join session "Access denied" (OnlineService)

**URL:** <https://forums.unrealengine.com/t/join-session-access-denied-onlineservice/1948060>\
**Category:** Multiplayer & Networking\
**Tags:** unreal-engine, question\
**Created:** [July 24, 2024, 4:57am UTC](https://forums.unrealengine.com/t/join-session-access-denied-onlineservice/1948060 "2024-07-24T04:57:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [July 24, 2024, 4:57am UTC](https://forums.unrealengine.com/t/join-session-access-denied-onlineservice/1948060/1 "2024-07-24T04:57:38Z")

</div>

This happen in my game.

1-I open two instances of the game  
2-One instance is the host and another is the client  
3-The client joins the session without problem  
4-Server travel  
5-Game  
6-The game ends  
7-Return to the main menu

Until now everything is perfect. I can repeat this process infinite times without problem and without closing the applications.

Now I want to change roles. The old client instance wants to be the new host and the old host wants to be the new client. In this point join session fails. I get the error “Access denied”.

Every time I return to the main munu I unregister the players and clean the session.

Does anyone know why this problem happens?

Thank you so much!!

* * *

EDITED

* * *

I found that the initial session is not completely deleted and that is why the old host cannot join the new session.

When I search for the new session the old session appears instead.

I am using this to destroy the session.

```auto
	auto Lambda = [](UE::Online::TOnlineResult<UE::Online::FLeaveSession> LeaveSessionResult)
	{
		if (!LeaveSessionResult.IsOk())
		{
			const FString Error = LeaveSessionResult.GetErrorValue().GetText().ToString();
			message::Error("FSessionCleaner::LeaveSession --> LeaveSessionResult is not Ok!! -->" + Error);
			return;
		}	
		message::Info("FSessionCleaner::LeaveSession -> DONE!!");
	};	

	UE::Online::FLeaveSession::Params Params = FLeaveSessionParams(Handler.GetAccountId(), DestroySession);
	UE::Online::TOnlineAsyncOpHandle<UE::Online::FLeaveSession> Handle = Handler.GetInterface()->LeaveSession( MoveTemp(Params) );
	Handle.OnComplete(Lambda);

```

It’s strange, because if after destroying the old session I don’t create a new one then it won’t find any session.

Only when I create a new one does the old session reappear.

Does this code have to be written somewhere special for it to work correctly?

I was using it in these functions:

```auto
APlayerController::OnNetCleanup(UNetConnection* Connection);
AGameMode::PostLogin(APlayerController* NewPlayer);

```

Any help is welcome!!  
Thank you so much!!

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [July 26, 2024, 3:09pm UTC](https://forums.unrealengine.com/t/join-session-access-denied-onlineservice/1948060/2 "2024-07-26T15:09:40Z")

</div>

Here are some possible solutions… but none of them work for me… maybe it’s because i’m using p2p … but they don’t work for me.

> [@How do I disconnect from a Dedicated Server the right way?](https://forums.unrealengine.com/t/how-do-i-disconnect-from-a-dedicated-server-the-right-way/336905):
>
> Simple question I feel, but right now the only way I can do this successfully is to attempt client travel that cannot occur, which forcibly disconnects the client from the server, I then destroy the session. I have tried the Logout node and the Destroy Session node by themselves and in unison, however it fails to send me back to the login screen, and the player controller can no longer interact with any online blueprint nodes. I would expect there to be a single command that disconnected the cli…

Is there a way to force the deletion of the cache where the sessions are stored?

I’ve been looking for a solution for three days. I appreciate any help.  
Thank you so much!!
