title: How to kill any session on basis of just SessionID
body: <p><em>Given that,</em></p>
  
  <p>I have a </p>
  
  <blockquote>
    <p>USER_ACTIVITY_LOG table</p>
  </blockquote>
  
  <p>that contains </p>
  
  <blockquote>
    <p>USER_ID,  SESSION_ID,  ACTIVITY_CODE(Login/LogOut/TimeOut) &amp;
    ACTIVITY_TIME columns</p>
  </blockquote>
  
  <p>in that. It updates all activities performed on the application in the table on basis of UserId &amp; SessionId.</p>
  
  <p><em>Problem Statement :</em>
  I want to restrict logins to maximum 2 users with the same credentials on my application.</p>
  
  <p>Say at a time 2 users are logged into the application with the same credentials (eg: admin/admin) and now 3rd user is trying to log into application with the same credentials. In such case the oldest logged in user session should be invalidated.</p>
  
  <p>I have to query <strong>USER_ACTIVITY_LOG</strong> table on every user login and check number of users logged in with the same userId and are not logged out.
  If I get count of 2 users that are still logged in, I simply want to <em>invalidate the session</em> of the oldest user on basis of just <strong>SESSION_ID</strong>. </p>
  
  <p>Is that possible ?</p>
  
  <p>My project is on Java 8, Jboss 6.4, J2EE, Struts 2 &amp; Oracle.</p>