title: Registration in php, session start and redirection
body: <p>I have the following registration.php file:</p>
  
  <pre><code>&lt;?php 
  include_once("QueryNew.php"); 
  
  if (!get_magic_quotes_gpc()) {
  
  $email=addslashes($_POST["email"]);
  $password=addslashes($_POST["password"]);
  $confirmpassword=addslashes($_POST["confirmpassword"]);
  $uid=uniqid();
  
  }
  
  if (trim($email," ") == "" || trim($password," ") == "" &amp;&amp; trim($confirmpassword," ") == ""){
      echo "&lt;script type='text/javascript'&gt;window.location='logintips.php?regErr=All fields are mandatory'&lt;/script&gt;";
  }
  
  if (trim($password," ") != trim($confirmpassword," ")){
      echo "&lt;script type='text/javascript'&gt;window.location='logintips.php?regErr=Passwords didnot match'&lt;/script&gt;";
  }
  
  if (trim($email," ") != "" || trim($password," ") != "" &amp;&amp; trim($confirmpassword," ") != ""){
  
          $insertQuery = "INSERT INTO user VALUES('".$uid."','".$email."','".$password."','',1,".CURRENT_TIMESTAMP.")";
          $qry = new QueryNew();
          $insert = $qry-&gt;executeSelect($insertQuery);
  
          $SELECT_STAR = "select uid, email, timezone from ";
  
          $selectQuery = $SELECT_STAR . "user" . " where email = '".$email."'";
  
          $qry = new QueryNew();
          $select = $qry-&gt;executeSelect($selectQuery);
  
          while($row = mysql_fetch_assoc($select)) {
              $uidS = $row['uid'];
              $emailS = $row['email'];
          }
  
  **//store $uidS and $emailS in a session variable and redirect to a (home) page**
  
  }
  ?&gt;
  </code></pre>
  
  <p>Once I am done with the insert and select queries, I want to create a session and redirect to someother page.. </p>
  
  <p>I tried session_start() as below:</p>
  
  <pre><code>        session_start();
          $_SESSION[uid] = $uidS;
          $_SESSION[email] = $emailS;
  
          echo $_SESSION[uid];
          echo $_SESSION[email];
  </code></pre>
  
  <p>Which gives an error:</p>
  
  <pre><code>**Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\website\try\MAIN\HOME\QueryNew.php:43) in C:\xampp\htdocs\website\try\MAIN\HOME\register.php on line 45**
  </code></pre>
  
  <p>If there is a better way than the above, please suggest.</p>