Check if user logged in globally

I have had an odd request from a customer to not allow changes to an individual’s configuration while they are logged in on any client. Not sure of the context at this stage as it’s 2nd-hand info.

However, is it possible to check if a user is logged into any client?

https://docs.inductiveautomation.com/display/DOC79/system.util.getSessionInfo

checkUser = 'jordancclark'
# Get Users that are logged in. Using a set will give unique usernames. 
userSet = set([row['username'] for row in system.util.getSessionInfo() if not row['isDesigner']]) 

userLoggedIn = checkUser in userSet

print userLoggedIn
1 Like

You can shorten it to this if you are only checking for one user. So a couple of different options.

userLoggedIn = len(system.util.getSessionInfo(checkUser))>0

EDIT: Note that this will not filter out designer sessions.

2 Likes

Awesome, thanks for the help :slight_smile: