title: Spring 4 for storing and retrieving Session from Cookie
body: <p>I am using Spring Security for login. However from what I have read Spring will store the session data in Memory. </p>
  
  <p>If I have multiple machines behind a load balancer then after logins authentications will start to fail because a JSESSIONID will not be present with the other Machine.</p>
  
  <p>One solution which I found was to store this data(session) in cookies and somehow not check for JSESSIONID and only check for expiration date and a symmetric key. The following link <a href="https://sleeplessinslc.blogspot.in/2012/02/spring-security-stateless-cookie-based.html" rel="nofollow noreferrer">Spring Security - Stateless Cookie Based Authentication with Java Config</a> explains how to do this.</p>
  
  <p>However in this solution we have to override all the filters in the chain and maintain it ourself, which is a tedious job. </p>
  
  <p>Is there some easier way to use this cookie based session.</p>
  
  <p><strong>NOTE</strong>: Some solutions online tell me to use some centralize dataStore but I want to avoid that because that will be an extra network call. </p>