Session Errors
Posted: Fri Nov 19, 2004 2:53 pm
What do these errors mean?
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /data/sites/89545/checks.org/www/newsite/cartedit.php:4) in /data/sites/89545/checks.org/www/newsite/cartedit.php on line 5
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /data/sites/89545/checks.org/www/newsite/cartedit.php:4) in /data/sites/89545/checks.org/www/newsite/cartedit.php on line 5
Here is the code:
</body>
</html>
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /data/sites/89545/checks.org/www/newsite/cartedit.php:4) in /data/sites/89545/checks.org/www/newsite/cartedit.php on line 5
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /data/sites/89545/checks.org/www/newsite/cartedit.php:4) in /data/sites/89545/checks.org/www/newsite/cartedit.php on line 5
Here is the code:
Code: Select all
<?php
<?
session_start();
if ($_POST['Add'] == "add")
{
//is session array has been set, then check that the product we are adding has not been added beforehand
if(isset($_SESSION['cart']))
{
$cartItem = sizeof($_SESSION["cart"]) + 1;
$_SESSION["cart"][$cartItem] = array( "Product_ID" => $_POST['Product_ID'],
"short_desc" => $_POST['short_desc'],
"style_ID" => $_POST['style_color'],
"price_ID" => $_POST['qty_price'],
"parts" => $_POST['parts']
);
}
}
//if the session array has not been created beforehand create cart session array
else
{
$cartItem = 0;
$_SESSION["cart"][$cartItem] = array( "Product_ID" => $_POST['Product_ID'],
"short_desc" => $_POST['short_desc'],
"style_ID" => $_POST['style_color'],
"price_ID" => $_POST['qty_price'],
"parts" => $_POST['parts']
);
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Cart Edit</title>
</head>
<body bgcolor="bdbd8d" leftmargin="0" marginheight="0" marginwidth="0" topmargin="0">
<? $i=0;
while($i < sizeof($_SESSION["cart"])) {
echo $_SESSION["cart"][$i]["Product_ID"];
echo $_SESSION["cart"][$i]["short_desc"];
echo $_SESSION["cart"][$i]["style_ID"];
echo $_SESSION["cart"][$i]["price_ID"];
echo $_SESSION["cart"][$i]["parts"];
$i++;
}
echo $_POST['Product_ID'];
echo $_POST['short_desc'];
echo $_POST['style_color'];
echo $_POST['qty_price'];
echo $_POST['parts'];
?>
?></html>