When I click on 'remember me' and after sign out, when I try again to login cookies are not retrieved
<p>I have a login form in which i have a username, password and a <em>remember me</em> radio button option. Now I want it so that when I've signed out from home page and I try again to login then without asking for a username and password I get logged in because I am going to store the username and password values into cookie.</p>

<p>I wrote code on password_match.php page(action page of login page)</p>

<pre><code>$con=mysql_connect("localhost","root","");
if(!$con)
{
die('Could Not Connect:'.mysql_error());
} 

mysql_select_db("tcs",$con);

if(isset($_COOKIE['cookname']) &amp;&amp; isset($_COOKIE['cookpass']))
{
$usr = $_COOKIE['cookname'];
$pwd = $_COOKIE['cookpass'];
$pwd=hash('sha1',$_POST['password']);
}

else
{
$usr=$_POST["username"];                 
$pwd=hash('sha1',$_POST['password']);           
}
</code></pre>

<p>Through this code I am checking is there any cookie with cookname and cookpassword which contain username and password. If no cookie is found with this name then retrieve username and password from textboxes directly, if the user enters them.</p>

<p>Now the code which I am going to write will set a cookie if username and password exists:</p>

<p>if ($result) 
{
        $row=mysql_fetch_array($result);</p>

<pre><code>if (($row["Username"]==$usr) &amp;&amp; ($row["Password"]==$pwd))
{
    if(isset($_POST['remember']))
    {
    setcookie("cookname", $row['Username'], time()+60*60*24*100, "/");
    setcookie("cookpass", $row['Password'], time()+60*60*24*100, "/");
    }


$_SESSION['employee']['id']=$row['User Id'];
    $_SESSION['employee']['username']=$row['Username'];

    header ("Location: home_page.php");
</code></pre>

<p>}</p>

<p>Now when starting, when I enter username and password and if these are right show a cookie must have been set and if now I am signed out and try the same sign in form, as according to me it should retrive cookie but nothing happining here. I am not able to implement it.  Where am I going wrong?</p>
