How to Prevent Session_id(); in PHP from Changing?
<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 am trying to create a sessions based hit counter. And my code doesn't seem to work. Whenever, i reload the page. The output is "YOU HAVE VIEWED THE PAGE 0 TIMES".</p>

<pre><code>    &lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
 &lt;?php
session_start();

if(!isset($_SESSION['count']))
    $_SESSION['count'] = 0;
else
    $_SESSION['count']++;

 echo "You Have Viewed this page ", $_SESSION['count'], " times.";  

 echo session_id(); ?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>When, i run this code on my localhost. The code simply doesn't work. And when i run it on my webserver(hostgator), i get following errors.</p>

<pre><code>Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/rohitink/public_html/uiet.org/s4/index.php:8) in /home/rohitink/public_html/uiet.org/s4/index.php on line 9

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/rohitink/public_html/uiet.org/s4/index.php:8) in /home/rohitink/public_html/uiet.org/s4/index.php on line 9
You Have Viewed this page 0 times.788141cfa1329643918f87f5f6c9eb5a
</code></pre>

<p>Please Give me details on How to Fix this error. Thank you very much.</p>
