Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

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

Avatar

Level 6

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

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

4 Replies

Avatar

Community Advisor

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

Avatar

Level 6

Thanks @arunpatidar ,

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

Avatar

Correct answer by
Community Advisor

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