title: How to force Tomcat to delete expired Sessions when loggin User closes his Browser?
body: <p>I implemented a SessionListener to track the open sessions of my webserver</p>
  
  <p>I set in my <code>web.xml</code>: </p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;listener&gt;
      &lt;listener-class&gt;demo.MyHttpSessionListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;session-config&gt;
      &lt;session-timeout&gt;1&lt;/session-timeout&gt; 
  &lt;/session-config&gt;
  </code></pre>
  
  <p>My demo.MyHttpSessionListener.groovy:</p>
  
  <pre><code>class MyHttpSessionListener implements HttpSessionListener {
     @Override
     public void sessionCreated(HttpSessionEvent event) {
      ...
     }
  
       @Override
       public void sessionDestroyed(HttpSessionEvent event) {
         ...
       }
  }
  </code></pre>
  
  <p>When I go to my website <strong>sessionCreated</strong> is called. <strong>sessionDestroyed</strong> is called when I close my browser an wait for the session timeout.</p>
  
  <p>The problem occurs when I loggin on my website and close my browser. In this case <strong>sessionDestroyed</strong> is never called after the timeout. Why will a session never be deleted when a user has been logged in and closes the browser?
  What do I have to do to get the expired sessions of a logged in user deleted after he closes his browser and waits the time out time?</p>