# Automatic Inactivity Detection possibilities

**URL:** <https://forum.inductiveautomation.com/t/automatic-inactivity-detection-possibilities/72756>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 21, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/automatic-inactivity-detection-possibilities/72756 "2023-04-21T13:12:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfenter](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@dfenter](https://forum.inductiveautomation.com/u/dfenter)\
**Post date:** [April 21, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/automatic-inactivity-detection-possibilities/72756/1 "2023-04-21T13:12:07Z")

</div>

I have a perspective project where authentication is not required. Security is setup on the tags so only certain users can write to tags, but all users can view tags. I would like to use the automatic inactivity detection (or property change script on the perspective session property lastActivity) to automatically logout an authenticated user after a set time period and redirect to a view using an unauthenticated user. Is this possible? Currently, after the automatic logout, it redirects to a page that states the user has been logged out of the session.

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [April 21, 2023, 2:34pm UTC](https://forum.inductiveautomation.com/t/automatic-inactivity-detection-possibilities/72756/2 "2023-04-21T14:34:30Z")

</div>

You can set up a script using the [`lastActivity` session prop](https://forum.inductiveautomation.com/t/perspective-run-script-after-inactivity-timer-elapses/43865/10) (I'd probably use a property bound to the current date, updating once per minute, with a change script like in [this post](https://forum.inductiveautomation.com/t/perspective-run-script-after-inactivity-timer-elapses/43865/6)) and then ~~call the [`system.security.switchUser()`](https://docs.inductiveautomation.com/display/DOC81/system.security.switchUser) function to switch to some "guest" user, since it seems like the `logout` function takes you to the login page again.~~

 

~~You could probably also have a script that automatically logs the user in to the "guest" user on session start, and hijack the logout button to switch user to your "guest" instead.~~ never mind, can't do that in Perspective

Maybe someone else has a ~~less complicated solution~~ solution that actually works though.

---

<div class="post-metadata">

**Author:** ![dfenter](https://avatars.discourse-cdn.com/v4/letter/d/87869e/32.png) [@dfenter](https://forum.inductiveautomation.com/u/dfenter)\
**Post date:** [April 21, 2023, 4:21pm UTC](https://forum.inductiveautomation.com/t/automatic-inactivity-detection-possibilities/72756/3 "2023-04-21T16:21:38Z")

</div>

system.security.switchUser only works in Vision unfortunately.

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [April 21, 2023, 4:45pm UTC](https://forum.inductiveautomation.com/t/automatic-inactivity-detection-possibilities/72756/4 "2023-04-21T16:45:04Z")

</div>

Oh yeah, I didn't notice that. Well there goes that idea out the window.

Maybe if you can have your IdP autologin to a "guest" account, this could still work, just with the regular logout feature?  
[[FEATURE-1402] Perspective “autologin” IdP](https://forum.inductiveautomation.com/t/feature-1402-perspective-autologin-idp/40221)

I guess that would still show the "logged out" screen.
