title: Registering PHP Session Variable
body: <p>I'm trying to create a simple login form. I have <code>session_start()</code>; as the first thing loaded on the page. I have a file login.php which contains the login related code which is processed through an ajax call when the Login button is clicked. It contains:</p>
  
  <pre><code>if ($_GET['cemail']) {
  
  $email = $_GET['cemail']; 
  $password = md5($_GET['cpassword']); 
  $sql = "select * from users where email='" . $email . "' and password='" . $password . "'";
  $result = mysql_query($sql);
  if (mysql_num_rows($result) &gt;= 1) { 
      session_register("email");
  }
  else {
      echo "&lt;span style='color:#ffffff;'&gt;Invalid Email/Password&lt;/span&gt;&lt;br&gt;";
  }
  
  }
  </code></pre>
  
  <p>When I click the Login button, I get this warning:</p>
  
  <blockquote>
    <p>Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /home/clicker/public_html/hstrial-RBochner/login.php:1) in /home/clicker/public_html/hstrial-RBochner/login.php on line 82</p>
  </blockquote>
  
  <p>Line 82 is the line that says <code>session_register("email")</code>;</p>
  
  <p>I also tried to create a Logout button which just calls <code>session_destroy()</code>, but it gives me this:</p>
  
  <blockquote>
    <p>Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/clicker/public_html/hstrial-RBochner/login.php on line 66</p>
  </blockquote>
  
  <p>What am I doing wrong here? I've tried placing <code>session_start()</code> in various places. Any help/ideas? Thanks.</p>