Power Portals – How to logout users programmatically

Requirement is to logoff without user intervention after some amount of time.

To achieve this I have used set time out function and redirecting to SignIn page

Below is the code

setTimeout(function(){ location.href = "https://<portalurl>/account/login/logoff" }, 60000)

I have added this function in Header web template in onload function, so that when user loads any page it will wait for defined time and logout automatically.

This function will make user to logoff and also redirects to SignIn page

Note: Additionally you can add to execute this function only when user is logged in or any other logic depending on your requirement

Hope its helpful..! 🙂

One thought on “Power Portals – How to logout users programmatically

  1. You could use the liquid value of ‘website.sign_out_url_substitution’ in your cod instead of ‘https:///account/login/logoff’.

    The benefit is that the value is no-longer hardcoded in the template, and when the user is signed out and then signs in again they will be returned to the page in the portal they were logged out from rather than signing back in to the home page.

    Liked by 1 person

Leave a comment