Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PHPCART A session had already been started

Community Beginner ,
Feb 26, 2007 Feb 26, 2007

Copy link to clipboard

Copied

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 = @MySQL_connect($server, $user, $pass);
$d = @MySQL_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();
}
}

?>
TOPICS
Server side applications

Views

234
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 26, 2007 Feb 26, 2007

Copy link to clipboard

Copied

LATEST
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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines