SpringBoot设置Session失效时间的解决方案

  private void configureSession(Context context) {

  long sessionTimeout = this.getSessionTimeoutInMinutes();

  context.setSessionTimeout((int)sessionTimeout);

  Boolean httpOnly = this.getSession().getCookie().getHttpOnly();

  if (httpOnly != null) {

  context.setUseHttpOnly(httpOnly);

  }

  if (this.getSession().isPersistent()) {

  Manager manager = context.getManager();

  if (manager == null) {

  manager = new StandardManager();

  context.setManager((Manager)manager);

  }

  this.configurePersistSession((Manager)manager);

  } else {

  context.addLifecycleListener(new TomcatServletWebServerFactory.DisablePersistSessionListener());

  }

  }