session_start() and header('location:') redirect
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8028957/headers-already-sent-by-php">Headers already sent by PHP</a>  </p>
</blockquote>



<p>I'm having a problem with <code>session_start()</code> and <code>header('Location:')</code> on a log out php file.</p>

<p>I'm linking to the log out file using a simple anchor tag from a html file. The logout php file is this:</p>

<pre><code>&lt;?php
session_start();
session_destroy();
header("Location: index.php");
?&gt; 
</code></pre>

<p>To see where the errors where I used,</p>

<pre><code>error_reporting(E_ALL);
ini_set('display_errors', '1');
</code></pre>

<p>I got a warning that "Warning: session_start(): Cannot send session cache limiter - headers already sent" on line 4 (where <code>session_start();</code> is) and Warning: Cannot modify header information - headers already sent on line 6 (where <code>header('Location')</code> is). </p>

<p>I've had a look around for others who have had similar problems. I've made sure there's no whitespace before the <code>session_start()</code>. Nothing is being outputted before it. I've tried only setting <code>session_start()</code> if it's not already set. I've tried buffering it with <code>ob_start()</code>. I tried a relative and absolute path for the redirect just to make sure. But nothing has worked.</p>

<p>Am I missing something? Any help is much appreciated.</p>
