title: Class Session PHP
body: <p>I have a class to generate the session_id, but every f5 it was renewed. </p>
  
  <p>How do I get it not to renew every f5?</p>
  
  <pre><code>&lt;?php
  
  class SessionIdSaf
  {
      function sessionGenerate() {
  
        $httponly = true;
        $session_hash = 'sha512';
        if (in_array($session_hash, hash_algos())) {
          ini_set('session.hash_function', $session_hash);
        }
        ini_set('session.hash_bits_per_character', 5);
        ini_set('session.use_only_cookies', 1);
  
        $cookieParams = session_get_cookie_params();
        session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], md5('secure'.$_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT']), $httponly);
        session_name(md5('secure'.$_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT']));
        session_start();
        return session_id();
  
    }
  
    function sessionRegenerate() {
  
      session_start();
      session_regenerate_id();
      return session_id();
  
    }
  
  }
  
  
  session_start();
  if (session_id()) {
      $sessionIdSaf           = new SessionIdSaf();
      $sessionIdSafGenerate   = $sessionIdSaf-&gt;sessionGenerate();
  }
  echo $sessionIdSafGenerate;
  </code></pre>
  
  <p>I want a simple class to generate the session_id and regenerate.</p>
  
  <p>Just to generate a session_id for all site visitors.</p>