title: How to solve: session_start(): Cannot send session cache limiter - headers already sent
body: <p>How to solve this error (session_start(): Cannot send session cache limiter - headers already sent (output started at /opt/lampp/htdocs/hrms/header.php:140))? This is login page.</p>
  
  <p><strong>Logs:</strong></p>
  
  <pre><code>PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /opt/lampp/htdocs/hrms/header.php:140) in /opt/lampp/htdocs/hrms/index.php on line 74
  
  PHP Warning:  Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/hrms/header.php:140) in /opt/lampp/htdocs/hrms/index.php on line 82
  </code></pre>
  
  <p><strong>line 74:</strong></p>
  
  <pre><code>session_start();
  </code></pre>
  
  <p><strong>line 82:</strong>   </p>
  
  <pre><code>header('location:home.php');
  </code></pre>
  
  <p><strong>Page:</strong></p>
  
  <pre><code>&lt;?php include('dbcon.php');include('header.php');?&gt;
  &lt;body&gt;
  &lt;?php include('nav-top1.php'); ?&gt;
  &lt;div class="wrapper"&gt;
  
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;div id="element" class="hero-body-index"&gt;
      &lt;div class="alert alert-info"&gt;
      &lt;p&gt;&lt;font color=""&gt;&lt;h2&gt;Login&lt;/h2&gt;&lt;/font&gt;&lt;/p&gt;
      Enter the details to login your account
      &lt;/div&gt;
  
      &lt;hr&gt;
      &lt;form method="POST" &gt;
      &lt;table&gt;
      &lt;tr&gt;&lt;td&gt;&lt;font color=""&gt;UserName:&lt;/font&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;input type="text"  name="UserName" class="UserName_hover"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;...&lt;td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;font color=""&gt;Password:&lt;/font&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;input type="Password" name="Password" class="Password_hover"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;...&lt;td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;   &lt;button class="btn btn-primary btn-large" name="Login"&gt;&lt;i class="icon-ok-sign icon-large"&gt;&lt;/i&gt;&amp;nbsp;Login&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;
      &lt;/td&gt;&lt;tr&gt;
      &lt;/form&gt;
      &lt;/table&gt;
  
      &lt;/br&gt;
      &lt;div class="error"&gt;
      &lt;?php
  
  if (isset($_POST['Login'])){
  
  $UserName=$_POST['UserName'];
  $Password=$_POST['Password'];
  
  $login_query=mysql_query("select * from user where UserName='$UserName' and Password='$Password' and User_Type='Admin'");
  $count=mysql_num_rows($login_query);
  
  $login_query1=mysql_query("select * from user where UserName='$UserName' and Password='$Password' and User_Type='User'");
  $count1=mysql_num_rows($login_query1);
  
  
  
  $row1=mysql_fetch_array($login_query1);
  $f=$row1['FirstName'];
  $l=$row1['LastName'];
  
  $row=mysql_fetch_array($login_query);
  $f=$row['FirstName'];
  $l=$row['LastName'];
  
  
  
  
  
  if ($count1 == 1){
  session_start();
  $_SESSION['id']=$row1['User_id'];
  $_SESSION['User_Type']=$row1['User_Type'];
  $type=$row1['User_Type'];
  
  mysql_query("INSERT INTO history (data,action,date,user)VALUES('$f $l', 'Login', NOW(),'$type')")or die(mysql_error());
  
  
  header('location:home_user.php');
  }
  
  if ($count &gt; 0){
  session_start();
  $_SESSION['id']=$row['User_id'];
  $_SESSION['User_Type']=$row['User_Type'];
  $type=$row['User_Type'];
  
  mysql_query("INSERT INTO history (data,action,date,user)VALUES('$f $l', 'Login', NOW(),'$type')")or die(mysql_error());
  
  
  header('location:home.php');
  }else{
  ?&gt;
      &lt;div class="alert alert-error"&gt;
      &lt;button class="close" data-dismiss="alert"&gt;Ч&lt;/button&gt;
     Please check your UserName and Password
      &lt;/div&gt;
  &lt;?php } 
  
  }
  
  ?&gt;  
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;/br&gt;
  &lt;?php include('footer.php');?&gt;
  
  
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>