How to change users without browser refresh by calling after .close()

While making a simple login webpage to test different users being able to log in and out of sessions, I can open a new router session with a new user, but the webpage console log indicates no valid session instance from within connection.onopen().

What I tried:
To logout old user, I call connection.close(), then I change user/secret. Then I call At first this didn’t work at the router, and I learned by looking at router logs that does not refresh the fields within var connection = new autobahn.Connection(). So I manually refreshed the connection variable with the new user info, and indeed that worked to start a new session at the router. However, at the client (webpage), console.log shows no valid autobahn.session instance.

Of course it works fine if I reload the browser as that reloads the entire js including connection.onopen = function(), but I’m trying to enable new users to login and out without refreshing the browser. I feel like this is a basic functionality and I’m missing something obvious!

I looked but did not find any actual web-page authentication code example with, say a simple button and text fields to change users/secrets and call again to get a new session going without refreshing browser.

For those looking for the solution wondering why you can’t reauthenticate with a new user after calling the obvious logout_() without browser refresh, I found part of it by looking through the metaapi examples. Specifically client.html and monitor.html which are full of useful examples:


  1. pull session variable outside the function scope to make it global, and
  2. reload the new authid, key and other variables (wampcra etc) into the connection parameters, then fire again.

Part 2) re-authenticating as a new authid is not explicitly exemplified in monitor.html, but metaapi examples cover everything else like how to kill sessions, removes authid, remove user role etc. I worked it out myself through trial and error as the old session variables persist in connection even after logout_().

Without doing both 1) and 2) it doesn’t seem possible to change authid, and even though I googled and searched crossbar docs and examples, I think I missed something obvious as logout_() is so complete in other respects, like deactivating the cookie if present.