title: How to understand "RESTful API is stateless"?
body: <p>I heard that a &quot;<strong>RESTful API should be stateless. All state info should be kept on client side</strong>&quot;.</p>
  <p>But when I issue an AJAX call from a web page, I noticed that a session ID cookie is always sent along to the server. With that session ID, I can obtain the session object on the server, and thus I can &quot;<strong>get/set some state info in the session</strong>&quot;.</p>
  <p>Does this break the &quot;code of being stateless&quot; for a RESTful API?</p>
  <h2>ADD 1</h2>
  <p>(The background of my question is as below.)</p>
  <p>I tried to implement a login page by calling a RESTful API to validate a username and a password.</p>
  <p>Each time a user attempts to visit a page of my site, a login <code>servlet filter</code> will check the <code>session</code> (this is where <code>getSession()</code> gets called) for that user to see if valid login info exists. If not, the login filter will redirect the user to the login page.</p>
  <p>On the login page, an AJAX call is made to a RESTful API on the server with the username and the password. Depending on the result of that RESTful API call, the JavaScript on the page will decide whether to let the user into my site.</p>
  <p>So, in this scenario, I kind of have to use <code>session</code>.</p>
  <p>The detailed code is located here:
  <a href="https://stackoverflow.com/questions/34146496/is-this-login-logic-via-restful-call-sound">Is this login logic via RESTful call sound?</a></p>