PHP Session not getting destroyed
<p>I am creating an application in PHP and stuck at the very beginning. I am having a simple login application. if i press the logout button i am getting redirected to my login page but if i again re-login with the same username and password either i am getting redirected to the same login page or i am getting wrong Welcome message from session.</p>

<p>The Following is the login form:</p>

<pre><code>&lt;form action="authenticate.php" method="post" autocomplete="off"&gt;
        &lt;table&gt;
            &lt;tr&gt;&lt;td&gt;Username:&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" class="rounded" name="uname" required placeholder="Enter username" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;
                &lt;td&gt;&lt;input type="password" class="rounded" name="pass" required placeholder="Enter Password" /&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;&lt;td&gt;&lt;input type="submit" value="Log in!" class="button"/&gt;&lt;/td&gt;&lt;/tr&gt;

        &lt;/table&gt;
</code></pre>

<p>This is the script for authenticate login: authenticate.php</p>

<pre><code>&lt;?php
session_start();
$host = 'localhost';
$user = 'root'; 
$password = 'root'; 
$db = 'slambook'; // 

$link = mysql_connect($host,$user,$password) or die('Error in Server information');
mysql_select_db($db,$link) or die('Can not Select Database');

$userName = mysql_real_escape_string($_POST['uname']); //User Name sent from Form
$password = mysql_real_escape_string($_POST['pass']); // Password sent from Form
$query="select * from users where fname='$userName' and password='$password'";
$res=mysql_query($query);
$rows=mysql_num_rows($res);
if($rows==1){
$_SESSION['userName'];
$_SESSION['password'];
header("Location: home.php");
    exit;
}
else{
header("Location: index.php");
    exit;
//echo 'Data Does Not Match &amp;lt;br /&amp;gt; Re-Enter UserName and Password';
}
?&gt;
</code></pre>

<p>The Following is the code for Logout:
logout.php</p>

<pre><code>&lt;?php
session_start();
session_unset();
header("Location: index.php");
exit();
</code></pre>

<p>?></p>
