Skip to Content
0
Jan 12, 2017 at 07:02 AM

Handling session Timeout in SAP HANA Cloud Portal

2205 Views Last edit May 27, 2020 at 08:09 AM 2 rev

Hi Experts,

I am working with HCP Portal SAPUI5 apps. I need to check the session before every data call is made to the backend so I can redirect the user back to the logon page.

In the HANA Cloud documentation, the below code is provided:

jQuery(document).ajaxComplete(function(e, jqXHR) {
  if (jqXHR.getResponseHeader("com.sap.cloud.security.login")) {
    alert("Session is expired, page shall be reloaded.");
    jQuery.sap.delayedCall(0, this, function() {
      location.reload(true);
    });
  }
});

Does the above code only works for both Ajax and oData calls. We want to redirect the user in every case to the logon page after session expiry.

Is there a direct method to achieve it both for oData calls and Ajax calls?