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?
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.
Awesome. Working as required.
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.
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.
@Teodor, is this logic the same if including the logic in a PHP include? In other words, I want to deploy this auto-logout feature throughout my entire site but the click action is failing to reset the counter.
I was able to resolve this issue by setting the Mouse Click/Move event on the App from the actual page. It was not working when the action was in the include file.
Hello again @brad!
I was wondering if you were ever ran across a solution that allowed for the log out to occur when the user was on another page/tab, or in other words to solve the issue you mentioned:
Having other tabs open and focused will nott activate the event.
The event should run as soon as the tab/page is focused again.
What I have done is hooked up my logout action to a scheduler for better control over the length. So if the scheduler hits while the page is not focused it will just wait and as soon as page is focused it should run the logout script.
Again, it’s been a couple years since I needed to do this so I’d have to go back and check my code exactly.
Here is my scheduler set up. After four hours it will trigger the logout action.
To reset the time if a staff member is actually on that page I have set an onClick event to the body tag that restarts the scheduler. So any time the user interacts with the page the scheduler restarts.
<body is="dmx-app" dmx-on:click="schedulerLogOut.start()">
That’s precisely what I did too. Thanks for your help (again) @brad!