title: Sessions not returning variables
body: <p>I am fairly new to php and trying to refamilarize myself with the information. I currently have a login script that is working fine until I set the variables - it checks the user/password fine but when it redirects to the echosession.php the $_SESSION['username']; variable does not echo. Also - checking if user is logged in works and logging out as well.</p>
  
  <pre><code>include 'db_connect.php';
  include 'functions.php';
  session_start();
  //user tabls
   $tbl_name="users";
  
  // username and password sent from form 
  $myusername=$_POST['username']; 
  $mypassword=$_POST['password']; 
  
  // To protect MySQL injection (more detail about MySQL injection)
  $myusername = stripslashes($myusername);
  $mypassword = md5($mypassword);
  $myusername = $mysqli-&gt;real_escape_string($myusername);
  $log_sql="SELECT * FROM $tbl_name WHERE email='$myusername' and password='$mypassword'";
  $log_result=$mysqli-&gt;query($log_sql);
  
    // Mysql_num_row is counting table row
    $log_count=$log_result-&gt;num_rows;
  
  // If result matched $myusername and $mypassword, table row must be 1 row
  if($log_count==1){
  
  // Register $myusername, $mypassword and redirect to file "login_success.php"
  
  // Set username session variable
  $_SESSION['username'] = $myusername;
  
  
  header("location:echosession.php");
  }
  else {
  echo "Wrong Username or Password";
  }
  </code></pre>
  
  <p>IF I try and load echosession.php as this:</p>
  
  <pre><code>session_start();
  print("hi");
  echo $_SESSION["username"];
  var_dump($_SESSION);
  </code></pre>
  
  <p>The page is just empty.</p>