title: How to make up a unique name for a $_SESSION in PHP?
body: <p>As part of the login system I'm making, I keep track of failed login attempts inside a unique session named after each client:</p>
  
  <pre><code>if($login_failed) {
  
              // update failed login attempts
              $session_name = 'failed_attempts'.$_SERVER['REMOTE_ADDR'];
  
              if(!isset($_SESSION[$session_name])) {
                  $_SESSION[$session_name] = 1;               
              }
              else {
                  $_SESSION[$session_name] += 1;  
              }
  
  }
  </code></pre>
  
  <p>As you can see, to determine a unique name for each session I append the user's IP address to the end of the string "failed_login_attempts".</p>
  
  <p>If the user reaches 5 failed attempts I require a captcha to be filled out on each subsequent attempt.</p>
  
  <p>I'm just worried that there might be some networks where many users are assigned the same IP address, in which case if 1 users fails to login they would all start seeing captchas even though only that 1 user needs to be shown the captcha. </p>
  
  <p>Is this reasonable or is there never a situation where 2 users can have the same IP, for example they may have the same first 3 octets but the last number will be different in which case I don't have to worry.</p>
  
  <p>If there is a chance of multiple users sharing the same IP then what is a good way to determine a unique identifier for my session name that will link a non-logged in user to the session?</p>