title: Why do my Spring Sessions keep getting deleted from my JDBC store?
body: <p>I am using Spring Sessions with Postgres. The sessions are persisted into my Postgres database using the <code>JdbcOperationsSessionRepository</code>.</p>
  
  <p>The default inactive time that I am using for my sessions is 30 days. Once a user logs in, I do <code>request.getSession().setMaxInactiveInterval()</code> and change it to 180 days.</p>
  
  <p>However for some reason the 180 days is not being respected and sessions keep getting deleted every hour. For example:</p>
  
  <p><img src="https://dl.dropboxusercontent.com/spa/urudiofz4a6071b/dcvg193z.png" alt=""></p>
  
  <p>This session should have lasted 180 days but it got deleted as soon as the next hour started.</p>
  
  <p>Does anyone know how I can stop these sessions from getting deleted and have them stick around for 180 days?</p>
  
  <p>I am guessing <a href="https://github.com/spring-projects/spring-session/blob/master/spring-session/src/main/java/org/springframework/session/jdbc/JdbcOperationsSessionRepository.java#L464" rel="nofollow">this function</a> has something to do with this.</p>
  
  <p>Here's the part of my application that extends the user's max inactive interval:</p>
  
  <pre><code>private void setupSession(HttpServletRequest request, User user) {
     HttpSession session = request.getSession();
     session.setMaxInactiveInterval(15552000);
     session.setAttribute("user-id", user.id);
  }
  </code></pre>