# Automatic user switch after timeout

**URL:** <https://forum.inductiveautomation.com/t/automatic-user-switch-after-timeout/8396>\
**Category:** Ignition\
**Created:** [April 30, 2014, 5:30pm UTC](https://forum.inductiveautomation.com/t/automatic-user-switch-after-timeout/8396 "2014-04-30T17:30:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcarritt](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@mcarritt](https://forum.inductiveautomation.com/u/mcarritt)\
**Post date:** [April 30, 2014, 5:30pm UTC](https://forum.inductiveautomation.com/t/automatic-user-switch-after-timeout/8396/1 "2014-04-30T17:30:12Z")

</div>

I’m trying to set up a client event script, under timer, that will log out the user admin and log in the operator user. user and operator are the only two users.

i have  
Check Inactivity @5,000ms

if system.util.getInactivitySeconds() \> 300:  
system.security.switchUser(Operator,operator,1)

Thanks.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 30, 2014, 6:27pm UTC](https://forum.inductiveautomation.com/t/automatic-user-switch-after-timeout/8396/2 "2014-04-30T18:27:54Z")

</div>

Here’s the script I currently use:

[code]

# Check to see how long since any keyboard or mouse activity from the user and

# if longer than 5 minutes lock the screen

if system.util.getInactivitySeconds() \> 300 and system.security.getUsername()!= “user”:  
if system.nav.getCurrentWindow() == “Main Windows/Setup”:  
system.nav.swapTo(“Main Windows/Main”)  
system.security.switchUser(“user”,“user”)  
else:  
system.security.switchUser(“user”,“user”)[/code]

If a logged in user is in the setup screen, it will swap back to the mail window and revert back to ‘user’. Otherwise, it will just revert back to ‘user’  
EDIT: Looking at what you have, it looks very close. You just need to put the username and password in quotes. 🙂

---

<div class="post-metadata">

**Author:** ![mcarritt](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@mcarritt](https://forum.inductiveautomation.com/u/mcarritt)\
**Post date:** [June 3, 2014, 6:10pm UTC](https://forum.inductiveautomation.com/t/automatic-user-switch-after-timeout/8396/3 "2014-06-03T18:10:51Z")

</div>

thank you, I think the quotes is really all I needed haha
