Remember me is not working in PHP
<p>When I try to login with username and password with checked option of remember me, and when I logged in and once again go back to login page I does not see username and password there, why it is so what I'm doing wrong???</p>

<pre><code>&lt;?php
$title   = "Login Page";
$heading = "Login Form";
include "includes/home_page_header.php";
?&gt;
&lt;?php
$cookie_username = $cookie_password = "";


if(isset($_POST['login']))
{
    //echo "&lt;pre&gt;"; print_r($_POST); echo "&lt;/pre&gt;";die;
    if(!empty($_POST['cookie_username']) &amp;&amp; !empty($_POST['cookie_password']))
    {
        $cookie_username = $_POST["cookie_username"]; 
        $cookie_password = $_POST["cookie_password"];
$sql_users="SELECT * FROM users WHERE username='$username' AND password='$password'";
$res_users = mysqli_query($link,$sql_users);

    if(mysqli_num_rows($res_users) &gt; 0 )
       {      
              $_SESSION["Username"]= $cookie_username;
              $_SESSION["Password"]= $cookie_password; 
              header('Location:http://localhost/sample/home_page.php');         
       }
       else
       {
            echo 'The username or password are incorrect!';
       }
    }


if($_POST['rememberMe'] =='on')
{       
    setcookie('cookie_username', $cookie_username, time() + (86400 * 30));
    setcookie('cookie_password', $cookie_password, time() + (86400 * 30));
    if(!isset($_COOKIE['cookie_username']))
    {
        echo "Cookie named '" . $cookie_username . "' is not set!";
    } 
    else 
    {
        echo "Cookie '" . $cookie_username . "' is set!&lt;br&gt;";
        echo "Value is: " . $_COOKIE['cookie_username'];
    }        
}
}
?&gt;

&lt;table class="login_table"&gt;
&lt;form name="login" action="" method="post"&gt;
&lt;tr&gt;
&lt;td&gt;User Name :-&lt;/td&gt;
&lt;td&gt;&lt;input type="text" name="cookie_username" value="&lt;?php echo $cookie_username;?&gt;"/&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Password :-&lt;/td&gt;
&lt;td&gt;&lt;input type="password" name="cookie_password" value="&lt;?php echo $cookie_password;?&gt;"/&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="checkbox" name="remember" &lt;?php if(isset($_COOKIE['remember'])) {
        echo 'checked="checked"';
    }
    else {
        echo '';
    }
    ?&gt; &gt;Remember Me
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;input type="submit" name="login" value="Login"/&gt;
&lt;input type="submit" name="cancel" value="Cancel"/&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/form&gt;
&lt;/table&gt;
</code></pre>