Page 1 of 1

send session cache limiter - headers already sent

Posted: Wed Feb 08, 2017 8:26 am
by jonnyfortis
i am getting a cache header error that is causing all sorted of problems. i have check to make sure the session start is at the top of the page and im still getting the error

send session cache limiter - headers already sent (output started at /home/defr/public_html/websco.uk/SS17/cartest.php:1) in /home/defr/public_html/websco.uk/SS17/XCInc/XCart.inc on line 4

this is one of the pages i am getting the error

Code: Select all

<?php
$XC_rowDelim = "|";
$XC_colDelim = "~";
if (!session_id()) session_start();
if (isset($_SESSION[$XCName."_"])) {
  // assert inputs against existing Session object
  if (sizeof($_SESSION[$XCName."_"]["ColNames"]) != sizeof($XC_ColNames)) {
    exit("Cart initialization error: The cart in the session does not match the cart on this page (123)");
  }
  ${$XCName}["ColNames"] = $_SESSION[$XCName."_"]["ColNames"];
  ${$XCName}["ComputedCols"] = $_SESSION[$XCName."_"]["ComputedCols"];
  ${$XCName}["CookieName"] = $_SESSION[$XCName."_"]["CookieName"];
  ${$XCName}["CookieLimName"] = $_SESSION[$XCName."_"]["CookieLimName"];
  ${$XCName}["CookieSrcName"] = $_SESSION[$XCName."_"]["CookieSrcName"];
  ${$XCName}["CookieOprName"] = $_SESSION[$XCName."_"]["CookieOprName"];
  ${$XCName}["Timeout"] = $_SESSION[$XCName."_"]["Timeout"];
  ${$XCName}["contents"] = $_SESSION[$XCName."_"]["contents"];
  ${$XCName}["limits"] = $_SESSION[$XCName."_"]["limits"];
  $XC_BindingSources = $_SESSION[$XCName."_"]["XC_BindingSources"];
  $XC_BindingOpers = $_SESSION[$XCName."_"]["XC_BindingOpers"];
} else {
  // Create a new session with the inputs
  ${$XCName}["ColNames"] = $XC_ColNames;
  ${$XCName}["ComputedCols"] = $XC_ComputedCols;
  ${$XCName}["CookieName"] = "_" . $XCName;
  ${$XCName}["CookieLimName"] = $XCName."Limits";
  ${$XCName}["CookieSrcName"] = $XCName."Sources";
  ${$XCName}["CookieOprName"] = $XCName."Opers";
  ${$XCName}["Timeout"] = $XCTimeout;
  ${$XCName}["contents"][] = array();
  ${$XCName}["limits"][] = array();
  // reconstitute cart from cookie if exists
  if (isset($_COOKIE[${$XCName}["CookieName"]])) {
    $XCCartRows = explode($XC_rowDelim,$_COOKIE[${$XCName}["CookieName"]]);
    $XCLimitRows = explode($XC_rowDelim,$_COOKIE[${$XCName}["CookieLimName"]]);
    $XC_BindingSources = explode(",",$_COOKIE[${$XCName}["CookieSrcName"]]);
    $XC_BindingOpers = explode(",",$_COOKIE[${$XCName}["CookieOprName"]]);
    for ($iRow=0; $iRow < sizeof($XCCartRows); $iRow++) {
      $XCCartCol = explode($XC_colDelim,$XCCartRows[$iRow]);
      $XCLimitCol = explode($XC_colDelim,$XCLimitRows[$iRow]);
      for ($iCol=0; $iCol < sizeof($XCCartCol); $iCol++) {
        ${$XCName}["contents"][$iCol][$iRow] = stripslashes($XCCartCol[$iCol]);
        ${$XCName}["limits"][$iCol][$iRow] = $XCLimitCol[$iCol];
      }
    }
    // assert inputs against existing Cookie object
    if (sizeof(${$XCName}["contents"]) != sizeof($XC_ColNames)) {
      exit("Cart initialization error: The cart in the cookie does not match the cart on this page (123)");
    }
  }
}
$XC_Shipping=0;
$XC_Discount=0;
$XC_SalesTax=0;
$XC_GranTotal=0;
$XCart__i=0;
$XC_indexProductID=array_search("ProductID",$XC_ColNames);
$XC_indexQuantity=array_search("Quantity",$XC_ColNames);
// *** X Shopping Cart sum ***
for ($col_i=0; $col_i<sizeof($XC_ColNames); $col_i++) {
  $sum_i = "XCart_sum".$XC_ColNames[$col_i];
  $$sum_i = 0;
  for ($jSum=0; $jSum < sizeof(${$XCName}["contents"][0]); $jSum++) {
    $$sum_i = $$sum_i + (float) ${$XCName}["contents"][$col_i][$jSum];
  }
}
?>

Re: send session cache limiter - headers already sent

Posted: Wed Feb 08, 2017 9:35 am
by requinix
Are you saving your pages in UTF-8 encoding? Make sure they do not have the BOM included - that appears before the opening <?php and PHP isn't smart enough to ignore it.