# Automatic logout after X amount of time

**URL:** <https://community.appfarm.io/t/automatic-logout-after-x-amount-of-time/1784>\
**Category:** Ask the community\
**Tags:** login\
**Created:** [April 8, 2025, 10:36am UTC](https://community.appfarm.io/t/automatic-logout-after-x-amount-of-time/1784 "2025-04-08T10:36:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![haider.ahmad](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@haider.ahmad](https://community.appfarm.io/u/haider.ahmad)\
**Post date:** [April 8, 2025, 10:36am UTC](https://community.appfarm.io/t/automatic-logout-after-x-amount-of-time/1784/1 "2025-04-08T10:36:03Z")

</div>

Hello Community!

So we use B2C with a JWT token which we use to authenticate to backend so after 1 hour the token expires and the actions will not work and give unauthorized error. So I’m looking into a forced logout option so after 45-60 minutes the user needs to log in again will the following setting be the option I would need to implement?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/1/158f0c8bd5c0004bac8fb976d8b69456075df8d0.png)

---

<div class="post-metadata">

**Author:** ![Johan18](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/johan18/32/748_2.png) [@Johan18](https://community.appfarm.io/u/Johan18)\
**Post date:** [April 8, 2025, 2:22pm UTC](https://community.appfarm.io/t/automatic-logout-after-x-amount-of-time/1784/2 "2025-04-08T14:22:04Z")

</div>

Hi Haider

I suppose you could use a timer in combination with the log out action node to log out the user after a certain amount of time.

Regards,  
Johan

---

<div class="post-metadata">

**Author:** ![haider.ahmad](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@haider.ahmad](https://community.appfarm.io/u/haider.ahmad)\
**Post date:** [April 9, 2025, 9:35am UTC](https://community.appfarm.io/t/automatic-logout-after-x-amount-of-time/1784/3 "2025-04-09T09:35:50Z")

</div>

Hello Johan!

Could you provide with an example?

---

<div class="post-metadata">

**Author:** ![haider.ahmad](https://avatars.discourse-cdn.com/v4/letter/h/2bfe46/32.png) [@haider.ahmad](https://community.appfarm.io/u/haider.ahmad)\
**Post date:** [April 9, 2025, 9:56am UTC](https://community.appfarm.io/t/automatic-logout-after-x-amount-of-time/1784/4 "2025-04-09T09:56:40Z")

</div>

Probably a very dumb question 😅! I was looking at other solutions and saw the code solution.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/b/b4a0222c1f2f15f435b9e77ad042dc3aa1eee16d.png)

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/5/50e3e915f00ae0398ffd906e5375c8036ce6d317.png)

I’m guessing that the problem lays in the calling of the actions, but not sure, tried different methods and can’t seem to get it to work. Could there be a setting i need to enable or does this might be outdated method?

---

<div class="post-metadata">

**Author:** ![Johan18](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/johan18/32/748_2.png) [@Johan18](https://community.appfarm.io/u/Johan18)\
**Post date:** [April 9, 2025, 10:01am UTC](https://community.appfarm.io/t/automatic-logout-after-x-amount-of-time/1784/5 "2025-04-09T10:01:06Z")

</div>

Hi

On app load set an app variable - “Logged in” Datetime

create a timer that fires an action every hour (inteval 3600 sec)

in the action

calculate time difference from logged in to now

if difference \> X hour (your limit)

- log out user

Probably there are other ways to do this as well..
