0
PHPCART A session had already been started
Community Beginner
,
/t5/dreamweaver-discussions/phpcart-a-session-had-already-been-started/td-p/640984
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();
}
}
?>
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
canacol
AUTHOR
Community Beginner
,
LATEST
/t5/dreamweaver-discussions/phpcart-a-session-had-already-been-started/m-p/640985#M171805
Feb 26, 2007
Feb 26, 2007
Copy link to clipboard
Copied
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
Sorry sorry, please some body know about this session problem?
carolina
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

