Auto log-out in perspective

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!!

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

2 Likes

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

Welcome to the forum, Kain. For future posts please see Wiki - how to post code on this forum.

1 Like

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:

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.