# Auto Logout (Switch Users)

**URL:** <https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [March 29, 2021, 6:35pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025 "2021-03-29T18:35:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [March 29, 2021, 6:35pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/1 "2021-03-29T18:35:39Z")

</div>

I would like to auto-logout after a certain amount of time, but instead of logging out of the client application, I just want to switch to a default user that has less roles for security. This should be per client.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 29, 2021, 6:41pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/2 "2021-03-29T18:41:17Z")

</div>

You could run a client timer script that checks [`system.util.getInactivitySeconds`](https://docs.inductiveautomation.com/display/DOC81/system.util.getInactivitySeconds) periodically, and conditionally calls [`system.security.switchUser`](https://docs.inductiveautomation.com/display/DOC81/system.security.switchUser).

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [March 29, 2021, 6:43pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/3 "2021-03-29T18:43:49Z")

</div>

Isn’t that a waste of processing power, to run a script that every couple of seconds to check a tag value. or am I overthinking how much power that would actually take.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 29, 2021, 6:46pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/4 "2021-03-29T18:46:34Z")

</div>

Vastly overestimating how much it would take to run. It’s not even a tag access - it’s literally just grabbing a value from memory. I can pretty much guarantee that the timer script would complete in milliseconds in the no-op case.

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [March 29, 2021, 6:47pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/5 "2021-03-29T18:47:18Z")

</div>

Alright I’ll do it like that then. Thanks for the help.

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [March 29, 2021, 7:00pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/6 "2021-03-29T19:00:58Z")

</div>

Alright, after adding this, it runs every second, now all of my templates on a screen blink every seconds, it is directly correlated to that script running

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [March 29, 2021, 7:08pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/7 "2021-03-29T19:08:28Z")

</div>

Only have switch user execute if it needs to do. Check if the specific user is logged in, if they are, don’t execute.  
[https://docs.inductiveautomation.com/display/DOC80/system.security.getUsername](https://docs.inductiveautomation.com/display/DOC80/system.security.getUsername)

---

<div class="post-metadata">

**Author:** ![rrebro](https://avatars.discourse-cdn.com/v4/letter/r/3da27b/32.png) [@rrebro](https://forum.inductiveautomation.com/u/rrebro)\
**Post date:** [March 29, 2021, 7:41pm UTC](https://forum.inductiveautomation.com/t/auto-logout-switch-users/45025/8 "2021-03-29T19:41:02Z")

</div>

Duh, that makes a lot of sense, otherwise it is just constantly logging out, lol. Thanks for the help
