Auto logout after X minutes

Hi there,

I followed instructions on an old topic but obviously I’m doing something wrong as I can’t seem to get this to work … probably somewhere in the Action Scheduler’s Tick Action …


Any ideas and/or suggestions? Thanks in advance.

Make sure you add your logout action to your page as a server connect data source with a noload on the action, then choose that inside the “tick” section of your action scheduler.

1 Like

Hi there, thanks for your fast reply. And uh … could you please explain a little further as I’m still rather new to Wappler and do not really understand what you’re trying to explain to me. Thanks again.

No problem, you see under your App in App Connect where you have things like Query Manager and API Data Source, just click on one of those, then click the Plus symbol and choose the catagory of Data and choose Server Connect.
Give it an ID and click Action, which will bring up a list of all your server actions, this is where you choose your logout action.
Make sure the checkbox No Auto Load is on.

Now click your action scheduler step, click the lighening symbol next to the tick section and choose the server connect data component you just added in the first step, save and test.

To be very honest, although what you are doing with using an action scheduler to count 10 minutes and then run the logout action will work perfectly, it is possibly more complicated than required.
Take a look at your login server action, you will see one of your steps should be a Security Provider, one of the properties of that should be Expires, which is by default set to 30 days.
I have never tried it so can not really be sure but I imagine there might be a way to set the cookie expiry to 10 minutes rather than 30 days however @Teodor would have to advise if my assumption is correct. Maybe it can be set to 0.01 or something.

If you don’t want to keep users logged in, then do not use cookies (do not use the remember me option) and the login will expire when the session expires. In most cases you can set on your host after which time a session expires, often this is after about 20min inactivity.

1 Like

Hi psweb, thanks for your time explaining this to me. I’ve tried this, but obiously I’m still doing something wrong …

Hi Patrick, thanks for your tip! Works really well :slight_smile:

1 Like

What you have done looks perfect to me, and should work as expected.

I imagine the action is running however it just gives no visual indication, to test this.
Open your webpage as a logged in user, open chrome developer tools, open the network tab, click XHR at the top.
Now in Wappler set your Action Scheduler to something like 1 minute for testing purposes. Save, Publish.
Refresh your browser page and wait 1 minute, you should see the script call and run inside the network area.

If it does as I suspect it should, then I imagine the logout is just not redirecting the user to another page after logout, please let me know if it runs and we can figure out redirecting after that.

1 Like