title: Session not creating causing no login
body: <p>I am creating a login script and am having trouble getting the user to login and direct to the correct page. Currently the user submits the login form which directs to the 'secure' page which checks the session matches as seen below however it seems to keep kicking me out.</p>
  
  <p>Here is my code - </p>
  
  <p>Login.php</p>
  
  <pre><code>session_start();
  include("clientarea/inc/config.php"); //Establishing connection with our database
  
  $error = ""; //Variable for storing our errors.
  if(isset($_POST["login"])){
  if(empty($_POST["email"]) || empty($_POST["password"])){
      $error = "Both fields are required";
  } else {
  // Define $email and $password
      $email = $_POST['email'];
      $password = $_POST['password'];
  
  // To protect from MySQL injection
      $email = mysqli_real_escape_string($connection, $email);
      $password = mysqli_real_escape_string($connection, $password);
      //$password = md5($password);
  
  //Check username and password from database
      $stmt = "SELECT * FROM users WHERE email='$email' and password='$password'";
      $result = mysqli_query($connection, $stmt); 
      $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  
  //If username and password exist in our database then create a session.
  
      if(mysqli_num_rows($result) == 1){
          $_SESSION['email'] = $login_user; // Initializing Session
          header("location: clientarea/index.php"); // Redirecting To Other Page
      } else {
          $error = "Incorrect username or password.";
      }
  }
  }
  </code></pre>
  
  <p>As you can see after the validation it check to see if there is a user and then directs to the 'secure' page.</p>
  
  <p>Here is auth.php</p>
  
  <pre><code>include('inc/config.php');
  session_start();
  $user_check = $_SESSION['email'];
  
  $sql = mysqli_query($connection, "SELECT email FROM users WHERE email='$user_check' ");
  
  $row = mysqli_fetch_array($sql,MYSQLI_ASSOC);
  
  $login_user = $row['email'];
  
  if(!isset($user_check))
  {
  header("Location: http://localhost/findpt/index.php");
  }
  </code></pre>
  
  <p>Now auth.php is run at the top of the 'secure' page to make sure the user is logged in otherwise redirect to the homepage. Now if I remove the auth.php file then I go straight to the 'secure' page fine but with it in place it boots me over to the homepage.</p>
  
  <p>If I echo $_SESSION['email'] I receive nothing?</p>