Auto Logout User on Session Expiry

Hi.
I have a secure page which checks if user is logged in or not via App Security Provider Enforcer. It works well.
I have not set any cookies or sessions to maintain user’s login session. Just the default PHP session timeout (30mins) is in play.
So, if I refresh the page which has been idle, after say 45 mins, I am redirected to login page.
Is there anyway I can redirect the page automatically after default PHP session times out?

1 Like

Hello @nshkrsh ,
If i understand you right, you want to auto run some kind of redirect/log out when the page has been inactive for like 45mins?
You can try using the action scheduler component.
Add the scheduler component, set its delay to 45min. Disable repeat.
Select app, select mouse > move > and add Action Scheduler > Start as an action to run, when your mouse moves. This will reset the delay every time the mouse is moved.

In the action scheduler, in the Tick option select your log out action > run.

5 Likes

Awesome. Working as required. :+1:

1 Like

I have found an issue with this logic.
When I have my page open and I move to another tab, the timer runs in the background as it should, but does not execute when it expires, i.e., tick event is not called until I switch back to the tab.
The issue with this mechanism is that if my mouse is on the tab body when tab is switched to (by keyboard), the mouse move event gets executed and timer restarts, without ticking.
But, if I click the tab (by mouse), the pending tick event gets executed.

So, instead of MOVE, I now use mouse CLICK event instead. So every time someone clicks on the page, timer restarts.

1 Like

Does the scheduler only restart when that particular page is clicked on or any mouse clicks in general? (Other browser tabs, other programs etc)

On the mouse move is this only on the webpage, for example if the webpage is open in the background and they are using an app
Would it still time out or does the mouse movement in the app keep it resetting ??

I can’t say for on move as I used on click. But as the code is on that particular page that page has tto be open in the browser. Having other tabs open and focused will nott activate the event.