title: PHP Autologin function to login script
body: <p>How would I implent an autologin feature to this script?</p>
  
  <pre><code>session_start();
  $result = mysql_query("SELECT id FROM users 
                         WHERE username = '{$_POST['username']}' 
                         AND password = '{$_POST['password']}'");
  
       if (isset($_POST['savelogin'])) {
       setcookie("SaveLogin", $_POST['username'], time()+3600);
       setcookie("SaveLogin", $_POST['password'], time()+3600);
       }
  
  
  if (mysql_num_rows($result) == 0) {
      exit('wrong username/password');
  
      } else {
      $_SESSION['id'] = mysql_result($result, 0, 'id');
      header("Location: ./");
      }
  
  
  
  &lt;form method="post"&gt;
  
  
  Username: &lt;input type="text" name="username" size="22" /&gt;&lt;br&gt;
  Password: &lt;input type="password" name="password" size="22" /&gt;&lt;br&gt;
  
  &lt;br&gt;
  Autologin? &lt;input type="checkbox" name="savelogin" /&gt;
  
  &lt;input type="submit" value="Login" /&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>Thats how far i have gotten. Saving the username and password. 
  But how should I do so it autologins?</p>