Can I use runtime.RUNTIME_CTX_VARS to pass value to server?

at server startup? or did you mean session startup, just to be sure

Yes sorry I forgot which thread I had answered. :slight_smile:

So technically setting session variables even before the session has been created didn’t feel right to me personally. Ideally, I would have created them in the after hook.

I think the problem with the after hook approach is that the lifecycle of after hooks are executed after the response has already gone on the socket. This behaviour could not be changed as it’d break the expectations of many games which use Nakama.

Besides, other session vars such as ‘paid user’, could change mid session.

You can easily update the session token with a custom RPC function and swap it out in the game client (though it would require you to reconnect the socket for those vars to be available). All the functions needed to modify the session token are available in the server runtime.