Detect Session time out and show alerts or redirect to Login page | Community
Skip to main content
akhilraj
Level 5
March 28, 2023
Solved

Detect Session time out and show alerts or redirect to Login page

  • March 28, 2023
  • 1 reply
  • 853 views

Hi Friends,

 

please help understand how we can detect the user session expiration programmatically and show alert box whether to continue or end the login user session?

 

We have enabled Azure SAML and after session is timed out, user is getting "Authentication Failed" message and nothing else when accessing same page.

 

How we can detect session expiry or presence of cookie and act accordingly(Redirect the user or some popup with link)?

 

Please help

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi @akhilraj 

 

You can check the resourceResolver in servlet from request, if null that means no session

ResourceResolver resourceResolver = request.getResourceResolver();

 

Unfortunately, I can't access that code anymore.

 

1 reply

arunpatidar
Community Advisor
Community Advisor
March 29, 2023

We had implemented a ajax call(every 5 second) to a servlet e.g. sessionCheck and based on response we redirected user to login page.

 

The sessionCheck servlet check if user is logged in or not based on the cookie or getting session in AEM based on request.

 

You can't check/access secure cookies at clientside. you have to make a call to server side to check the cookie or user status.

Arun Patidar
akhilraj
akhilrajAuthor
Level 5
April 4, 2023

Thanks @arunpatidar ,

If you can share some code snippet based on it, will be helpful.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
April 4, 2023

Hi @akhilraj 

 

You can check the resourceResolver in servlet from request, if null that means no session

ResourceResolver resourceResolver = request.getResourceResolver();

 

Unfortunately, I can't access that code anymore.

 

Arun Patidar