# Auto log-out in perspective

**URL:** <https://forum.inductiveautomation.com/t/auto-log-out-in-perspective/101615>\
**Category:** Ignition\
**Tags:** perspective, scripting\
**Created:** [January 30, 2025, 1:59pm UTC](https://forum.inductiveautomation.com/t/auto-log-out-in-perspective/101615 "2025-01-30T13:59:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kain\_Denon](https://avatars.discourse-cdn.com/v4/letter/k/e68b1a/32.png) [@Kain\_Denon](https://forum.inductiveautomation.com/u/Kain_Denon)\
**Post date:** [January 30, 2025, 1:59pm UTC](https://forum.inductiveautomation.com/t/auto-log-out-in-perspective/101615/1 "2025-01-30T13:59:49Z")

</div>

While working on a project, I want to introduce the functionality that users get automatically logged out after x amount of time inactivity. I have introduced a logout button with the script "system.perspective.logout()" that works.

Also i have added a custom session property "lastActivity : 0" and a onMouseMove script

"def runAction(self, event):  
import time  
self.session.custom.lastActivity = int(time.time())"

in the root containers of the views to recognise if someone is active.

I need to know if this sill even work and a script that makes the auto log-out possible... Also, where do i best implement this script? Under Gateway Event Scripts \> Timer or Session Events Script \> Startup?

Thanks in advance!!

---

<div class="post-metadata">

**Author:** ![dillon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dillon/32/81537_2.png) [@dillon](https://forum.inductiveautomation.com/u/dillon)\
**Post date:** [January 30, 2025, 2:03pm UTC](https://forum.inductiveautomation.com/t/auto-log-out-in-perspective/101615/2 "2025-01-30T14:03:24Z")

</div>

Have you tried using the settings provided in the project's properties?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/6/f6de99b50ae4840a7e9560eda63ad5e7c39aff5f.png)

---

<div class="post-metadata">

**Author:** ![Kain\_Denon](https://avatars.discourse-cdn.com/v4/letter/k/e68b1a/32.png) [@Kain\_Denon](https://forum.inductiveautomation.com/u/Kain_Denon)\
**Post date:** [January 30, 2025, 2:17pm UTC](https://forum.inductiveautomation.com/t/auto-log-out-in-perspective/101615/3 "2025-01-30T14:17:28Z")

</div>

Thank you! The activity detection works on MouseClick but i'm guessing the detection based on mouse movement works with a script?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [January 30, 2025, 2:48pm UTC](https://forum.inductiveautomation.com/t/auto-log-out-in-perspective/101615/4 "2025-01-30T14:48:02Z")

</div>

Welcome to the forum, Kain. For future posts please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<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:** [January 30, 2025, 7:28pm UTC](https://forum.inductiveautomation.com/t/auto-log-out-in-perspective/101615/5 "2025-01-30T19:28:40Z")

</div>

> [@Kain\_Denon](#):
>
> Also, where do i best implement this script? Under Gateway Event Scripts \> Timer or Session Events Script \> Startup?

If you need custom logic outside of the options given in the project properties, you should add a change script to the `lastActivity` session property:

> **[Session Properties | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/perspective-sessions/session-properties#device---settings)**
>
> Session properties are available for use throughout Perspective Sessions. Sessions of a given project will have the same list of properties, however, the actual values are unique and independent for each running Session.

That would allow you to directly invoke a script that does whatever you want.  
But only do this if you actually have to do something more complicated than the options in the project properties.
