title: logout problem in PHP with session
body: <p>I'm trying to make a login and logout script for a page but for some reason its not working very well for me. it seems to work fine until I try to logout. it seems to destroy the session variables, but it still lets me view the page. 
   heres my login code: </p>
  
  <p>Code:
  login.php</p>
  
  <pre><code>&lt;?php
  // Use session variable on this page. This function must put on the top of page.
  
  session_start();
  ////// Logout Section. Delete all session variable.
  session_destroy();
  $Name=$_POST['Name'];
  $Pass=$_POST['Pass'];
  
  // To protect MySQL injection (more detail about MySQL injection)
  
  $Name = stripslashes($Name);
  $Pass = stripslashes($Pass);
  $Name = mysql_real_escape_string($Name);
  $Pass = mysql_real_escape_string($Pass);
  
  $sql="SELECT * FROM reg1 WHERE uname='$Name' and pass='$Pass'";
  $result=mysql_query($sql);
  if(mysql_num_rows($result)!='0') // If match.
  {
  session_register("uname"); // Craete session username.
  header("location:loged.php"); // Re-direct to loged.php
  exit;
  }else{ // If not match.
  echo '&lt;script type="text/javascript"&gt;
          window.alert("Wrong UserName And Password");
          window.location="index.php"
          &lt;/script&gt;';
  }
  
   // End Login authorize check.
  
  
  
  ?&gt;
  </code></pre>
  
  <p>logout.php</p>
  
  <hr>
  
  <pre><code>&lt;?php
  
  // Inialize session
  session_start();
  
  // Delete certain session
  unset($_SESSION['uname']);
  // Delete all session variables
  session_destroy();
  
  // Jump to login page
   header("Location: index.php?msg=Successfully Logged out");
   }
  
  
  ?&gt;
  </code></pre>
  
  <p>thanks to every one...</p>