# Automatic User Log Off

**URL:** <https://forum.inductiveautomation.com/t/automatic-user-log-off/9513>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 7, 2015, 5:03pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513 "2015-01-07T17:03:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [January 7, 2015, 5:03pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/1 "2015-01-07T17:03:30Z")

</div>

Possible to automatically log a user off of a client after a certain amount of time?

---

<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:** [January 7, 2015, 8:09pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/2 "2015-01-07T20:09:30Z")

</div>

Hi Paul,

There is a default inactivity script that goes to a lockout screen, but can easily be changed to use system.security.logout, or system.security.switchUser if you want to put it to a default user.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e3809b99c98cbf3e30b99f3b40fc69e0ab6509e4.png)

---

<div class="post-metadata">

**Author:** ![Paullys50](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paullys50/32/3324_2.png) [@Paullys50](https://forum.inductiveautomation.com/u/Paullys50)\
**Post date:** [January 7, 2015, 9:31pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/3 "2015-01-07T21:31:40Z")

</div>

Great that gets me moving in the direction I want to go!

---

<div class="post-metadata">

**Author:** ![hpatel](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@hpatel](https://forum.inductiveautomation.com/u/hpatel)\
**Post date:** [June 27, 2018, 1:37pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/4 "2018-06-27T13:37:54Z")

</div>

This is very helpful. I tried system.security.switchUser but keep getting login failed. Is there a way to assign a default user?

---

<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:** [July 3, 2018, 10:46am UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/5 "2018-07-03T10:46:12Z")

</div>

Sorry, been on vacation. There is no default user setting.

Did you set it up per the docs? ([https://docs.inductiveautomation.com/display/DOC79/system.security.switchUser](https://docs.inductiveautomation.com/display/DOC79/system.security.switchUser))

Does the user exist in the security profile you are using for the project?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [July 3, 2018, 4:56pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/6 "2018-07-03T16:56:37Z")

</div>

> [@hpatel](#):
>
> Is there a way to assign a default user?

If you setup your project for auto login (project properties), the user you've setup for auto login will be the default user as auto login will also occur when you logout.

---

<div class="post-metadata">

**Author:** ![hpatel](https://avatars.discourse-cdn.com/v4/letter/h/7ab992/32.png) [@hpatel](https://forum.inductiveautomation.com/u/hpatel)\
**Post date:** [July 3, 2018, 5:12pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/7 "2018-07-03T17:12:51Z")

</div>

Thanks Jordan. I eventually got it working a few days ago using a user profile. The docs did help.

---

<div class="post-metadata">

**Author:** ![Samuel\_Porter](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/samuel_porter/32/52836_2.png) [@Samuel\_Porter](https://forum.inductiveautomation.com/u/Samuel_Porter)\
**Post date:** [December 4, 2023, 3:47pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/8 "2023-12-04T15:47:35Z")

</div>

I know this is a very old thread, but if anyone comes here wanting a 10 minutes auto-logout script, here's the one I configured running as a 5 second Timer Client script:

```auto
# Check to see how long inactivity on the client has been active and
# if longer than 10 minutes, switch to the default operator account

if system.util.getInactivitySeconds() > 600 and system.security.getUsername() != "default username":
	system.security.switchUser("default username","default password")

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 4, 2023, 3:50pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/9 "2023-12-04T15:50:32Z")

</div>

This topic is old enough that it is Vision-only implicitly (Perspective didn't exist then). Just to warn newer visitors that this is a Vision-only solution.

---

<div class="post-metadata">

**Author:** ![Elmer\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Elmer\_Sanchez](https://forum.inductiveautomation.com/u/Elmer_Sanchez)\
**Post date:** [September 18, 2024, 2:15pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/10 "2024-09-18T14:15:14Z")

</div>

How would you go about logging out only once? I tested this out and the script runs continuously from inactivity.

---

<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:** [September 18, 2024, 3:27pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/11 "2024-09-18T15:27:26Z")

</div>

Are you trying to log out of the application or go back to a default user?

---

<div class="post-metadata">

**Author:** ![Elmer\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Elmer\_Sanchez](https://forum.inductiveautomation.com/u/Elmer_Sanchez)\
**Post date:** [September 18, 2024, 5:45pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/12 "2024-09-18T17:45:52Z")

</div>

Go back to a default user. I was able to figure it out by using a while loop instead of an "if" function.

---

<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:** [September 18, 2024, 5:56pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/13 "2024-09-18T17:56:07Z")

</div>

Did you use @Samuel_Porter's example?

```python
# Check to see how long inactivity on the client has been active and
# if longer than 10 minutes, switch to the default operator account

if system.util.getInactivitySeconds() > 600 and system.security.getUsername() != "default username":
	system.security.switchUser("default username","default password")

```

---

<div class="post-metadata">

**Author:** ![Elmer\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Elmer\_Sanchez](https://forum.inductiveautomation.com/u/Elmer_Sanchez)\
**Post date:** [September 23, 2024, 4:55pm UTC](https://forum.inductiveautomation.com/t/automatic-user-log-off/9513/14 "2024-09-23T16:55:44Z")

</div>

Yes I did and changed the if to while.
