title: Spring Session in Clustered Environment
body: <p>We have two apps that are shared sessions by the "Spring Session" between them.
  In apps, there is a Form that Admin can force logout other online users. before we use "Spring Session", we get all online user from <code>SessionRegistry</code> and use below method for force logout user. but now when a user login to app1, <code>SessionRegistry</code> of app1 hold session Info but <code>SessionRegistry</code> of app2 not hold!</p>
  
  <p><a href="https://i.stack.imgur.com/7szQI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7szQI.jpg" alt="enter image description here"></a></p>
  
  <pre><code>public void forceLogOut(int userId) {
      for (Object username : sessionRegistry.getAllPrincipals()) {
          User temp = (User) username;
          if (temp.getId().equals(userId)) {
              for (SessionInformation session : sessionRegistry.getAllSessions(username, false)) {
                  sessionRegistry.getSessionInformation(session.getSessionId()).expireNow();
              }
          }
      }
  }
  </code></pre>
  
  <p>We have two questions:</p>
  
  <ol>
  <li>when a user logged in from app1, app2 can not get all online user! how can I get all online users (same result) from tow app? </li>
  <li>above method is not working, when I force logout one user from app2, that logged in from app1. what is the best way?</li>
  </ol>