title: How to get the JSESSIONID from Contexts.getSession() during preDestroyContext.SESSION?
body: <p>Working with JBoss AS 5.1, JSF 1.2 and Seam 2.2, I'm trying to log session openings and closings.</p>
  
  <p>AFAIK, at the moment of the <code>org.jboss.seam.preDestroyContext.SESSION</code> event, in case of a session timeout, there's no <code>FacesContext</code> which seems natural as there is no running HTTP request, so I can't get the session ID from it. But there's still a Seam session context which is available by <code>Contexts.getSession()</code>.</p>
  
  <p>When I dynamically inspect the <code>Contexts.getSession()</code> object in a debugger, I can see the <code>JSESSIONID</code> in some inner <code>Map</code>. I would like to do something like: </p>
  
  <pre><code>String sessionId = Contexts.getSession().get("JSESSIONID");
  </code></pre>
  
  <p>But apparently, <code>JSESSIONID</code> is not the right key to retrieve the session ID. I tried <code>id</code>, <code>SessionId</code> without success. The <code>SessionContext.getNames()</code> method returns a list of keys:</p>
  
  <ul>
  <li><code>anonPersistentPermissionResolver</code></li>
  <li><code>loggedUserId</code></li>
  <li><code>org.jboss.seam.security.ruleBasedPermissionResolver</code></li>
  <li><code>org.jboss.seam.web.session</code></li>
  <li><code>com.sun.faces.application.StateManagerImpl.SerialId</code></li>
  <li><code>org.jboss.seam.international.timeZoneSelector</code></li>
  <li><code>org.jboss.seam.international.localeSelector</code></li>
  <li><code>org.jboss.seam.security.defaultResolverChain</code></li>
  <li><code>org.jboss.seam.security.persistentPermissionResolver</code></li>
  <li><code>javax.faces.request.charset</code></li>
  <li><code>crumbs</code></li>
  <li><code>org.jboss.seam.core.conversationEntries</code></li>
  <li><code>debateId</code></li>
  <li><code>org.jboss.seam.security.credentials</code></li>
  <li><code>com.sun.faces.logicalViewMap</code></li>
  <li><code>org.jboss.seam.security.identity</code></li>
  <li><code>org.jboss.seam.security.rememberMe</code></li>
  </ul>
  
  <p>The value for <code>org.jboss.seam.web.session</code> doesn't contain the session ID.</p>
  
  <p>How do I get the session ID from <code>Contexts.getSession()</code>?</p>