title: Sessions controlled manually
body: <p>I am trying to create a unique session per user to store some data. The user's in this case are http requests coming from an IOS app so there is no browser here its just using HTTP as a convenience. Hence there is not automagic session suppport. Each client is uniquely identified so I wanted to use that name as their session key. The goal is to count how many times each client has sent a message to us.</p>
  
  
  
  <pre><code>session_name($sname."S");
  session_start();
  
  //If we have a stored server message index in the session we will use that instead of what
  //we pulled from that database
  if(isset($_SESSION['count']))
  {
      $serverMessageIndex = $_SESSION['count'];
  }
  else
  {
      $serverMessageIndex = $msgIndex - 1;
  }
  
  //Later
  
  $_SESSION['count'] = $serverMessageIndex + 1;
  </code></pre>
  
  
  
  <p>The idea here is that no message from the client can be sent twice with the same number because the counter keeps going up. However when I tried this out by sending a number of requests each with a higher number then the last, a printout of $serverMessageIndex showed 2,2,7,2,2,7 where as I would have expected 1,2,3,4,5,6,7</p>
  
  <p>Details on how the client sends this:
  A ios app is generating a url request with only 1 paramater. This is a json variable encrypted and base64 encoded. The php is pulling from that json the variable $sname above. This variable is going to be available in every request that comes from the client.</p>