title: Setting $_SESSION doesn't work on localhost using XAMPP
body: <p>I set my session like so in my PHP code : <code>$_SESSION['user_id'] = $login;</code> and this seems to work fine whilst uploaded to my server and carries across different pages, however when I am testing the website on my local machine the session seems to become immediately unset after leaving the script where it is set.</p>
  
  <p>I am testing on my local machine using XAMPP and exactly the same code.</p>
  
  <p>I am not sure why this problem is occurring and would greatly appreciate any helpful answer.</p>
  
  <h3>Example that is not working:</h3>
  
  <pre><code>$_SESSION['user_id'] = $login;
  echo '&lt;META HTTP-EQUIV="refresh" content="0;URL=../home.php"&gt;';  
  </code></pre>
  
  <h3>EDIT 1:</h3>
  
  <p>Here is my entire function in which I <em>log in</em> (it's part of the class):</p>
  
  <pre><code>public function loggingIn(){
      session_start();
  
      $db = new Database('localhost','root','','userdata');
      $userFunctions = new Users($db);
  
      $username = $_POST['usernameInput'];
      $password = $_POST['passwordInput'];
  
      if(empty($username) || empty($password)){
          $this-&gt;errors['u&amp;p'] = 'Please Enter Your Username AND Password';
          $this-&gt;printE();
      } elseif($userFunctions-&gt;user_exists($username)===false){
          $this-&gt;errors['nm'] = 'That Username/Password Combination Is Not Valid';
          $this-&gt;printE();
      } else {
              $login = $userFunctions-&gt;login($username, $password);
  
      if($login === false){
              $this-&gt;errors['nm'] = 'That Username/Password Combination Is Not Valid';
              echo 'Login Failed!';
          } else  {
             if(!$userFunctions-&gt;economyTableExistsForUser($login)){
                 $userFunctions-&gt;createEconomyTableForUser($login);   
             }
             if(!$userFunctions-&gt;schoolTableExistsForUser($login)) {
                 $userFunctions-&gt;createSchoolTableForUser($login);    
             }
  
                 $_SESSION['user_id'] = $login;
  
                 echo $_SESSION['user_id'];  // working fine
  
                 header('Location: ../home.php');
          }
      }   
  }
  </code></pre>