title: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started in php
body: <p>I have been created php online chat.</p>
  
  <p>Here is my index.php:</p>
  
  <pre><code>&lt;?php
  session_start();
  function loginForm(){
      echo'
      &lt;div id="loginform"&gt;
      &lt;form action="index.php" method="post"&gt;
          &lt;p&gt;Please enter your name to continue:&lt;/p&gt;
          &lt;label for="name"&gt;Name:&lt;/label&gt;
          &lt;input type="text" name="name" id="name" /&gt;
          &lt;input type="submit" name="enter" id="enter" value="Enter" /&gt;
      &lt;/form&gt;
      &lt;/div&gt;
      ';
  }
  
  if(isset($_POST['enter'])){
      if($_POST['name'] != ""){
          $_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name']));
      }
      else{
          echo '&lt;span class="error"&gt;Please type in a name&lt;/span&gt;';
      }
  }
  ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;Chat&lt;/title&gt;
  &lt;link type="text/css" rel="stylesheet" href="style.css" /&gt;
  &lt;/head&gt;
  
  
  
  &lt;?php
  if(!isset($_SESSION['name'])){
      loginForm();
  }
  else{
  ?&gt;
  &lt;div id="wrapper"&gt;
      &lt;div id="menu"&gt;
          &lt;p class="welcome"&gt;Welcome, &lt;b&gt;&lt;?php echo $_SESSION['name']; ?&gt;&lt;/b&gt;&lt;/p&gt;
          &lt;p class="logout"&gt;&lt;a id="exit" href="#"&gt;Exit Chat&lt;/a&gt;&lt;/p&gt;
          &lt;div style="clear:both"&gt;&lt;/div&gt;
      &lt;/div&gt;    
      &lt;div id="chatbox"&gt;&lt;/div&gt;
  
      &lt;form name="message" action=""&gt;
          &lt;input name="usermsg" type="text" id="usermsg" size="63" /&gt;
          &lt;input name="submitmsg" type="submit"  id="submitmsg" value="Send" /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  // jQuery Document
  $(document).ready(function(){
      //If user submits the form
      $("#submitmsg").click(function(){   
          var clientmsg = $("#usermsg").val();
          $.post("post.php", {text: clientmsg});              
          $("#usermsg").attr("value", "");
          return false;
      });
  
      //Load the file containing the chat log
      function loadLog(){     
  
          $.ajax({
              url: "log.html",
              cache: false,
              success: function(html){        
                  $("#chatbox").html(html); //Insert chat log into the #chatbox div               
              },
          });
      }
  
      //Load the file containing the chat log
      function loadLog(){     
          var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20; //Scroll height before the request
          $.ajax({
              url: "log.html",
              cache: false,
              success: function(html){        
                  $("#chatbox").html(html); //Insert chat log into the #chatbox div   
  
                  //Auto-scroll           
                  var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20; //Scroll height after the request
                  if(newscrollHeight &gt; oldscrollHeight){
                      $("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal'); //Autoscroll to bottom of div
                  }               
              },
          });
      }
  
      setInterval (loadLog, 2500);    //Reload file every 2500 ms or x ms if you w
  });
  &lt;/script&gt;
  &lt;?php
  }
  ?&gt;
  &lt;script type="text/javascript"&gt;
  // jQuery Document
  $(document).ready(function(){
      //If user wants to end session
      $("#exit").click(function(){
          var exit = confirm("Are you sure you want to end the session?");
          if(exit==true){window.location = 'index.php?logout=true';}      
      });
  });
  &lt;/script&gt;
  &lt;?php 
  if(isset($_GET['logout'])){ 
  
      //Simple exit message
      $fp = fopen("log.html", 'a');
      fwrite($fp, "&lt;div class='msgln'&gt;&lt;i&gt;User ". $_SESSION['name'] ." has left the chat session.&lt;/i&gt;&lt;br&gt;&lt;/div&gt;");
      fclose($fp);
  
      session_destroy();
      header("Location: index.php"); //Redirect the user
  }
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When i run this code above i got warning like this,</p>
  
  <blockquote>
    <p>Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\selva\php\onlinechat\chat\index.php:1) in C:\xampp\htdocs\selva\php\onlinechat\chat\index.php on line 2</p>
  </blockquote>
  
  <p>i followed all other stackoverlfow resources and modified some changes..</p>
  
  <p>But still the above warning is showing.</p>
  
  <p>Can anyone help me to fix this?</p>
  
  <p>Thanks.</p>