title: PHP session_name(): Cannot change session name when session is active Error
body: <p>I am getting some unexpected errors on some code which has been working for a few weeks. I haven't changed this code yet I'm getting two errors upon logging in.</p>
  
  <blockquote>
    <p>session_name(): Cannot change session name when session is active in
    /opt/lampp/htdocs/FantasyKicks/index.php on line 5</p>
    
    <p>session_start(): A session had already been started - ignoring in
    /opt/lampp/htdocs/FantasyKicks/index.php on line 7</p>
  </blockquote>
  
  <p>I have tried running session_destroy() to put me back on the login page and delete the session and then taking that line out and logging back in, but both errors still appears. I am wondering if there is actually an issue with how I've coded the logging in process or not.</p>
  
  <p><strong>login.php</strong> (i've taken out some irrelevant code on this page)</p>
  
  <pre><code>session_name('FantasyKicks');
  
  session_start();
  
  if(!$email &amp; !$password) {
          echo "All fields required";
      } else {
          if(!$email) {
              echo "Email required";
          } else {
              if(!$password) {
                  echo "Password required";
              } else {
                  if($num == 0) {
                      echo "Incorrect email or password";
                  } else {
                      // User is logged in
                      echo "LoggedIn";
                      $_SESSION['UserID'] = $user['UserID'];
                      $_SESSION['Email'] = $user['Email'];
                      $_SESSION['FirstName'] = $user['FirstName'];
                      $_SESSION['LastName'] = $user['LastName'];
                      $_SESSION['logged_in'] = true;
                  }
              }
          }
      }
  
  </code></pre>
  
  <p><strong>index.php</strong> (start of index.php)</p>
  
  <pre><code>require 'fkdb.php'; // Connect to database which uses XML config file
  
  session_name('FantasyKicks');
  
  session_start();
  if (!isset($_SESSION['logged_in'])) {
     $_SESSION['logged_in'] = false;
  };
  </code></pre>