title: Setup a session in PHP
body: <p>I don't seem to understand how I can setup a session. I wrote this code: </p>
  
  <pre><code>&lt;?php
  require_once '../database/Database.php';
  session_start();
  $database = new Database('localhost', 'root', '');
  
  
  if(isset($_POST['login'])){
      $username = $_POST['username'];
      $password = $_POST['password'];
      if($database-&gt;login($username, $password)){
          $loggedIn = $_SESSION['loggedIn'] = true; 
          header("location: ../dashboard/dashboard.php");
      }
      else{
          echo "You've failed to login";
      }
  }
  ?&gt;
  &lt;h2&gt;&lt;!--&lt;a href="../index.php" role="button" class="btn btn-info btn-circle"&gt;&lt;i class="fa fa-home"&gt;&lt;/i&gt;&lt;/a&gt;--&gt;&lt;button class="btn btn-info btn-circle"&gt;&lt;i class="fa fa-info"&gt;&lt;/i&gt;&lt;/button&gt;&lt;/h2&gt;
  &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-4"&gt;
              &lt;div class="information"&gt;
              &lt;h5&gt;Additional Information&lt;/h5&gt;
              &lt;p&gt;
                  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur malesuada, magna sed sagittis posuere, nulla massa vulputate erat, sed laoreet mi nisl id quam. Nunc sodales justo quis orci sagittis tincidunt. Aliquam consectetur, metus vel commodo molestie, dui nisl vulputate nunc, sit amet varius ex nisi a ante. Donec vitae semper enim. Nullam vulputate porttitor interdum. Phasellus vel vehicula ligula, sit amet consectetur nunc. Phasellus eget facilisis arcu, sed fringilla neque. Sed urna purus, dictum eu condimentum eu, egestas vitae lacus. Nam ultricies nec ligula quis consectetur. Suspendisse posuere nulla tortor, vel pulvinar nulla fermentum non. Sed quis nulla sed mi congue sollicitudin. Morbi consectetur mi quis mauris egestas commodo. Vivamus rhoncus vestibulum orci, quis aliquam velit convallis eget.
              &lt;/p&gt;
          &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="col-md-4"&gt;
              &lt;div class="panel panel-default"&gt;
                  &lt;div class="panel-heading"&gt;
                      &lt;img src="../assets/logo.png"&gt;
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;form accept-charset="UTF-8" role="form" method="post"&gt;
                          &lt;fieldset&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;input class="form-control" placeholder="Username" name="username" type="text"&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;input class="form-control" placeholder="Password" name="password" type="password"&gt;
                              &lt;/div&gt;
                              &lt;input class="btn btn-info btn-block" type="submit" name ="login" value="Login"&gt;
                          &lt;/fieldset&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="col-md-4"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Database function: </p>
  
  <pre><code>public function login($username, $password){
          $this-&gt;connection = mysqli_connect($this-&gt;host, $this-&gt;dbUsername, $this-&gt;dbPassword, 'portal');
          $query = mysqli_query($this-&gt;connection, "SELECT * FROM users WHERE password='$password' AND username='$username'");
          if(mysqli_num_rows($query) != 0){
              return true;
          }
          else{
              return false;
          }
      }
  </code></pre>
  
  <p>I want to start a session when a user logs in and store this one. So when the user reloads the login page he/she's still logged in. Could anyone help me out</p>