There is no specific event, because a logout simply reloads the page resulting in the user seeing the login form again. You cannot execute any custom code if not logged in, because you don't have any connection to the server yet as the websocket connection has to be authenticated before being able to do that. However, to "catch" a login simply add a LocalScript somewhere in your HMI that is shown by default - that will be executed everytime that area is shown - as is true for all LocalScripts. You could however simply add the UI action "write item" followed by "logout (final)" on a logout button - this will write the item and logout the user. Please note that it says "final", because you cannot add any more UI actions after that one, because as described before the page is simply reloaded. Please keep in mind that you can have potentially unlimited numbers of users logged in at the same time in your HMI (depending on the "clients" part of your license, by default two) that can access completely different parts of the HMI. As such your requirement only works if there will ever only be a single user at all logged in to your HMI at the same time. Otherwise, the latest user will always overwrite the previous one. Please also note that if the network connection breaks for whatever reason you will not be able to catch the implicit logout - it will still appear as "loggedin" in your PLC then. You could however simply create a LocalScript that writes the username every few seconds so you can detect in the HMI if it's not written anymore which would mean that there is no active user anymore. Still, you have to handle multiple users logged in at once.
... View more