title: Disabling Cookies stops Session as well?
body: <p>I have been building a Web Application, So far I have implemented Login &amp; Registration. User can register and then can login within the web application. Everything is working fine. What I am doing is When user clicks on <code>Login</code> button, a servlet is being invoked where I'm checking if the credentials are correct, If validated then Saving <code>isLoggedIn</code> in <code>HttpSession</code> and redirecting it to <code>Home Page</code>.</p>
  
  <p><strong>LoginServlet.java</strong></p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
      boolean isValidated = false;
      ... // Service Layer is invoked here and checks for user validation
  
      // Assume isValidated to be true
      if(isValidated){
          HttpSession session = request.getSession();
          session.setAttribute("isLoggedIn", Boolean.valueOf(true));
          ...
          // redirected to /home
      }else{
          // redirected to /login?invalid
      }
  }
  </code></pre>
  
  <p><strong>HomeController.java</strong></p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
  
      HttpSession session = request.getSession();
      Boolean isLoggedIn = (Boolean) session.getAttribute("isLoggedIn");
      if(isLoggedIn != null &amp;&amp; isLoggedIn){
          ...
          // Service Layer is invoked to fetch `Home Page Data`
      }else{
          // redirected to /login?expired
      }
  }
  </code></pre>
  
  <p>All of a sudden I have encountered a strange problem, If i disable cookies for localhost using <code>FireBug</code> I am not able to login anymore. No matter if I enter correct username or password each time I am being redirected to <code>/login?expired</code>.</p>
  
  <p>I don't get it, Cookies are ment to be stored at client side and Session are stored at Server side, then Why session attribute can not be set if Cookies are disabled.</p>
  
  <p><strong>I have tried disabling Cookies for already built Web Application in Spring-MVC which is in production and having same issue there as well.</strong></p>