title: php login session handling issue
body: <p>this is my login form php codes. in my knowledge this code is ok but there is a issue with session handling. I think there is no session creating in my code. but can't see any error be course I research it many resources many of them proof this. any help must be appreciated.    </p>
  
  <p><strong>home page -</strong> </p>
  
  <pre><code>&lt;?php
  
  session_start();
  session_regenerate_id();
  if(!isset($_SESSION['user']))      // if there is no valid session
  {
      header("Location: login.html?action=no");
  die();
  } else {
  
  }
  ?&gt;
  </code></pre>
  
  <p><strong>login page(index.php)</strong> - </p>
  
  <pre><code>&lt;?php 
  
  if(isset($_POST['submit']))
  { 
      $dbHost = "localhost";        //Location Of Database usually its localhost 
      $dbUser = "root";            //Database User Name 
      $dbPass = "";            //Database Password 
      $dbDatabase = "testdb";    //Database Name 
  
      $db = mysql_connect($dbHost,$dbUser,$dbPass)or die("Error connecting to database."); 
      //Connect to the databasse 
      mysql_select_db($dbDatabase, $db)or die("Couldn't select the database."); 
      //Selects the database 
  
      /* 
         The Above code can be in a different file, then you can place include'filename.php';      instead. 
      */ 
  
      //Lets search the databse for the user name and password 
      //Choose some sort of password encryption, I choose sha256 
      //Password function (Not In all versions of MySQL). 
      $usr = mysql_real_escape_string($_POST['username']); 
      $pas = hash('sha256', mysql_real_escape_string($_POST['password'])); 
      $sql = mysql_query("SELECT * FROM users_table  
          WHERE username='$usr' AND 
          password='$pas' 
          LIMIT 1"); 
      session_start();
      if(isset($_POST['username']) &amp;&amp; isset($_POST['password']))
      {
          if( auth($_POST['username'], $_POST['password']) )
          {
              // auth okay, setup session
              $_SESSION['user'] == $_POST['username'];
              isset($_SESSION['user']);
              session_register("user");
              // redirect to required page
              $Groups = $result["Groups"];
  
              if($Group == 'a')
              { // "Admin"
                  $_SESSION['user'] == $_POST['username'];
                  isset($_SESSION['user']);
                  session_register("user");
                  header("Location: video.html");
              } elseif($Group == 'admin') {
                  $_SESSION['user'] == $_POST['username'];
                  isset($_SESSION['user']);
                  session_register("user");
                  header("Location: home.html");
              } else {
                  // didn't auth go back to loginform
                  header( "Location: index.html" );
              }
          }
      }
  
  ?&gt;
  </code></pre>