title: Warning: session_start(): Cannot start session when headers already sent in (...) on line 2
body: <p>My code:</p>
  <pre><code>    &lt;?php
      session_start();
      
      $_SESSION[&quot;favcolor&quot;] = &quot;green&quot;;
      ?&gt;
  
  &lt;html&gt;
      
  
      
    &lt;head&gt;
  
      &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
      &lt;meta charset=&quot;utf-8&quot;&gt;
      &lt;title&gt;Login | NeonBLOX&lt;/title&gt;
      
     charset stuff
  
    &lt;/head&gt;
  
    &lt;body&gt;
      
      &lt;?php
      
         $_SESSION[&quot;favcolor&quot;] = &quot;green&quot;;
      
      ?&gt;
      
      &lt;div class=&quot;ib2&quot;&gt;
         top stuff
      &lt;/div&gt;
      
      &lt;div class=&quot;ib&quot;&gt;
          form stuff
      &lt;/div&gt;
      
  
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Why does it error <em>Warning: session_start(): Cannot start session when headers already sent in (...) on line 2</em>? I'm trying to test session stuff with my current site, so I can make it so I send information that is preset to another web page, but it gives me this error before I even log in.</p>