title: setcookie() always fails "headers already sent" even following the rules on php.net
body: <p>The relevant peice of code is below. According to php.net I have to make sure there is no output, not even any whitespace. There isn't any. the php tag is the very first tag in the document no whitespace preceding it. What am I doing wrong?</p>
  
  <pre><code>&lt;?php
  
      // main.php
      // 6:48 PM 8/6/2010
  
      include('config.php');
  
      // Does myid cookie exist?
      if ( !isset( $_COOKIE['myid'] ) )
      {
          // Generate myid
          $myid = substr(md5(date( 'Ymdhis' ) . str_replace( '.', '', $_SERVER['REMOTE_ADDR'] ) ), 0, 10);
  
          // set the cookie
          setcookie( 'myid', $myid, time() + 31536000 );
  </code></pre>