You can always view who is using a client live on the gateway via the Status page -
I believe it just tells you the user and you can see their recent client logs.
If you want this sort of thing logged to a database with more info, I think it’s on you to to write a Startup client event script that saves a record to the database that the current user with current permissions logged in at X time, and a Shutdown script to tell the database the user logged off.
I think the second part of this might be a little more prone to being problematic - a power outage turning off a client is not going to give the time to tell the database that the user logged out.
However, if you don’t care to create an audit trail, you can prepopulate your table with all users, have a column called loggedOn or something like that with a datetime being null, and then when they log on set the loggedOn to the current time, when they log off set it to null. Save the permissions level as well.
For the second scenario where you don’t care about auditing every log on/off, you can then query to see the highest current user by
SELECT * FROM logOnTable WHERE loggedOn IS NOT NULL ORDER BY permissions DESC LIMIT 1
If you do want an audit trail you can still write a query to find it but it would be slightly more complicated.