Update:
After reverting everything back to its original and redeploying to the Mendix Cloud, the Sign Out button is working as expected.
Hi Kevin,
The functionality you require is exactly the functionality that MendixSSO offers:
- when arriving the first time on the login page, you see the Mendix SSO login button;
- clicking that button logs you in, if you are logged in to Mendix. If you are not logged in to Mendix, you will see the Mendix-login page;
- closing the browser and opening it again, returning to the application url will log you in again;
- clicking the logout button will log you out locally and show you your login page, including the MendixSSO login button
So there is no need for the javascript magic. The hardest part of going from being a coder to being a Mendix consultant is first exploring all Mendix' options before resorting to the code again.
Where did the SSO-implementing go wrong? It seems to function fine, since you can log in according to your description.