title: Are php sessions stateless or not?
body: <p>I know this question was asked many times regarding the use of php sessions in RESTful SPIs, but the answer is usually that php sessions preserve the state across multiple request, thus are not stateless, and since I have doubts about this claim I would like to contradict it and receive good answers:</p>
  
  <p>If I understand php sessions right, this is how they work:</p>
  
  <ul>
  <li>When a user requests a resource that involves session handling a
  session id is produced and provided to him.</li>
  <li>The user is responsible to send this session id to the server for any subsequent requests,
  which is usually done by the user-agent via cookies or by attaching a session-id parameter<br>
  to the url.</li>
  </ul>
  
  <p>Thus, no application state information is ever saved on the server, and php sessions ARE stateless, as the session id is saved by the client, not the server.</p>
  
  <p>Of course, there's the session file that IS saved on the server, hence the preserved state. But what is the difference between saving info on this session file, or saving it in a database? sessions or not, some data is saved on the server, and some of it (or all of it) is only relevant to a certain user or a group of users.</p>
  
  <p>Assume a chess game for example. Assume all game logic is implemented in php files. Soldier positions are saved in a table. Player must identify somehow to tell the server what move to do next. Now assume soldier positions are saved in a session file. Player has to identify again, is this scenario any different than the db table scenario?</p>
  
  <p>EDIT:
  Thanks for the good answers, they rise another question: can session-based applications (such as the chess game from last paragraph) be implemented as a RESTful service?</p>