Page 1 of 1

Error with cookie

Posted: Tue Apr 01, 2003 11:12 am
by wizzard
Warning: Cannot add header information - headers already sent by (output started at /usr/local/psa/home/vhosts/xxxxx.com/httpdocs/dmd/header.php:26) in /usr/local/psa/home/vhosts/xxxxx.com/httpdocs/dmd/cart.php on line 12


Thats the function:

function GetCartId()
{
if(isset($_COOKIE["cartid"]))
{
return $_COOKIE["cartid"];
}
else
{
session_start();
setcookie("cartid", session_id(), time() + ((3600 * 24) * 30));
return session_id();
}
}


Don't know whats wrong with this:

setcookie("cartid", session_id(), time() + ((3600 * 24) * 30));

Can someone helps me?

Cheerz
Kris

Posted: Tue Apr 01, 2003 11:46 am
by twigletmac
Have a read of:
viewtopic.php?t=1157

Mac

Posted: Tue Apr 01, 2003 11:50 am
by wizzard
setcookie("cartid", session_id(), time() + ((3600 * 24) * 30));

i always get an error first. Then it makes the cookie and i don't have an error anymore.

Posted: Tue Apr 01, 2003 12:31 pm
by twigletmac
Did you read the stickie I linked to above? It explains what causes this error.

Mac

Posted: Wed Apr 02, 2003 3:38 am
by wizzard
Thanks it works now strange you cannot call the function getcartid after there is already code send to the browser.

Regards
Kris