Skip to main content
Participant
February 26, 2007
Question

PHPCART A session had already been started

  • February 26, 2007
  • 1 reply
  • 259 views
Hi,

I doing a cart for a client, that just requeried, that his cart send by e-mail all products that the users choice in the catalog. that's works fine...
but I have a session error every new item select, and display in the cart. any one can help me to fix this?.

I based all with this tuturial..
http://www.adobe.com/devnet/dreamweaver/articles/php_cart.html

The error is this..

Notice: A session had already been started - ignoring session_start() in D:\www\peachpit\php_cart\db.php on line 41

Warning: Cannot modify header information - headers already sent by (output started at D:\www\shopcorp\php_cart\db.php:41) in D:\www\shopcorp\php_cart\db.php on line 42

thanks for any help with this?
this is the code..
<?php

// This page contains the connection routine for the
// database as well as getting the ID of the cart, etc

$dbServer = "localhost";
$dbUser = "root";
$dbPass = "";
$dbName = "cart";

function ConnectToDb($server, $user, $pass, $database)
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.

$s = @6688122_connect($server, $user, $pass);
$d = @6688122_select_db($database, $s);

if(!$s || !$d)
return false;
else
return true;
}

function GetCartId()
{
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table

if(isset($_COOKIE["cartId"]))
{
return $_COOKIE["cartId"];
}
else
{
// There is no cookie set. We will set the cookie
// and return the value of the users session ID

session_start();
setcookie("cartId", session_id(), time() + ((3600 * 24) * 30));
return session_id();
}
}

?>
This topic has been closed for replies.

1 reply

canacolAuthor
Participant
February 27, 2007
I sorry, I doble click the send button, that is why that appears doble this post..

Sorry sorry, please some body know about this session problem?

carolina