Dynamically reconnecting socket with new params

Hi I am having a SPA and dynamically login/logout via a Ajax requests that delivers me a valid user-token on login or deletes the session on logout. As a callback of these functions I want to implement an automatic reconnect of the socket to force a rejoin of all channels based on the new authorization.
I did try the following:
Login:
socket.disconnect(() => { socket.params.userToken = token socket.connect() })
Logout:
socket.disconnect(() => { socket.params.userToken = null socket.connect() })
It however seems that nothing is happening on the server and channels are not rejoined. How would I force such a rejoin with new socket params?

:wave:

You’d probably need to keep a set of currently joined channel topics, and rejoin all of them on disconnect / reconnect “manually.”

i did the authentification on a channel and renewed via socket.channel("name", params) instead of userChannel.params = {}. That did the trick Thanks anyways!