remember me feature for login page
<p>i need remember me feature in my code. i'm set session but i don't know idea about set cookie for remember me. please set remember me code in below my login page. i'm tried many sites but i'm not get exact output.</p>

<pre><code>&lt;?php 
session_start();
ob_start();
error_reporting (E_ALL ^ E_NOTICE);
$con=mysql_connect("localhost","root","");
mysql_select_db("pratice") or die (mysql_error());
$username=$_POST['username'];
$password=$_POST['password'];
$remember=$_POST['remember'];

if(isset($_POST['submit']))
{
$sql="select id, username FROM `action2` WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
$num=mysql_num_rows($result);

if($num&gt;0)
{
    $row=mysql_fetch_array($result);
    $username=$row['username'];
    $_SESSION['id'] = $row['id'];
    $_SESSION['username']=$username;
    header("location:userpage.php");
}
else 
{
echo"&lt;p&gt;&lt;center&gt;&lt;b&gt;&lt;font color='red'&gt;Incorrect Username or Password!&lt;/font&gt;&lt;/b&gt;&lt;/center&gt;&lt;/p&gt;";
}
}
?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Log In&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="&lt;?php $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt; 
&lt;table align="center"&gt;
&lt;tr&gt;
    &lt;td colspan="2"&gt;LOGIN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;Username&lt;/td&gt;
    &lt;td&gt;&lt;input type="text" name="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" name="password" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td align="right"&gt;&lt;input name="remember" type="checkbox" value=""/&gt;&lt;/td&gt;
    &lt;td&gt;Remember me&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td colspan="2" align="center"&gt;&lt;input type="submit" name="submit" value="LogIn" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;br /&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
