ATG application session implementation

Tools:

  • ATG 10.2
  • Weblogic 10.2.3

Target:

Handle time based session expiry and redirect user to home page.

Overview:

A servlet can be inserted into the dafpipeline through which all requests are passed, using out of the box component we can know if the session has expired for this request, once found we can take appropriate action like redirecting user to session time out page or home page.

Steps:

Configure time in weblogic

Home Page -> Domain Structure -> Deploymnets -> <Your deployment> -> Configuration tab -> Session Timeout (in seconds):

Default value is 1800 seconds i.e. 30 minutes

weblogictimeout

To apply session into atg app, we need to create pipeline servlet component using one of the following:

  1. projects.b2bstore.servlet. WACheckSessionExpiration
  2. projects.b2bstore.servlet. CheckSessionExpiration

 

If you are using WACheckSessionExpiration:

Create a property file like following:

$class=atg.projects.b2bstore.servlet.WACheckSessionExpiration
 # Specify where in the servlet pipeline this servlet should appear
insertAfterServlet=/atg/dynamo/servlet/dafpipeline/SessionSaverServlet
# Specify the root path (relative to the web app context root) of URLs'
# that we should check for session expiration
relativeExpirationPath=/checkout
# Specify the URL (relative to the web app context root) that we should
# redirect to if an expired session is detected.
relativeExpirationURL=/home
# Specify the web application registry where app is registered
webAppRegistry=/atg/registry/webappregistry/ServletContextWebAppRegistry
# Specify the name under which the web app is registered
webApplicationName=<Web App name>

If you are using CheckSessionExpiration:

Create a property file like following:

$class=atg.projects.b2bstore.servlet.CheckSessionExpiration
# Specify where in the servlet pipeline this servlet should appear
insertAfterServlet=/atg/dynamo/servlet/dafpipeline/SessionSaverServlet
#Complete URL where user would be redirected in case of session expiry
expirationURL=http://myhomepage.es
#Session would be checked for files under this directory only
sessionExpirationPath=/store/checkout

 

AJAX Calls:

Above solution would work for form submission but not for AJAX calls, by adding following to your JS file which is common for all pages you can handle the scenario.

$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
if(jqxhr.status == 0){
window.location.href = ‘http://myhomepage.es’;
}
});

 

This is a global error method for AJAX which would be called for all AJAX errors.

As pipeline would redirect the request to home page, it will cause AJAX calls to fail hence status would be 0 and then you can do any action you want.