title: How to keep session alive in angular JS
body: <p>I am working on web application in which we have angularJS as UI  and java as back end. We have configured tomcat server session timeout to 20 minutes. AngularJS is responsible for fetching and saving data. When the data size is huge sometime it takes more than 20 minutes to process the request which is fine as per our business requirement.</p>
  
  <p>We are facing issue if any ajax request takes more than 20 minutes. Whenever any operation takes more than 20 minutes session goes timeout however angularJS still waits for data to be returned. ajax request to server is not able to keep session alive. We checked it by opening a new tab in browser it asks for login where first tab waits for data to be returned.</p>
  
  <p>Is there any way to keep the session alive till the server processing the request.</p>
  
  <p>Below is my angularJS code to make request to server.B</p>
  
  <pre><code>return $http({
              method: method,
              url: url,
              async:true,
              data: $.param(data),
              headers: {
                  'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                  'X-Requested-With':'XMLHttpRequest'
              }
          }).then(function(response){
             if(response.status ===200){
                  // do  some work
             }               else{
                 failureCallBack(response.data, response.status, response);
             }
          });
  </code></pre>