Re: Session for creating a unique shopping cart for each user

From: Date: Fri, 31 Oct 2003 14:48:59 +0000
Subject: Re: Session for creating a unique shopping cart for each user
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-168225@lists.php.net to get a copy of this message
Have you already sent anything to the browser? Once the first echo has been performed, you can't send header information, as the header is sent with the first bit of text. On Friday, Oct 31, 2003, at 15:47 Europe/Amsterdam, Tore E. Mackay wrote:
Hi, I am creating a shopping cart but experiensing some difficulty in creating unique shopping carts for each user. When I try to create a session I get this error message: Warning: session_start(): Cannot send session cookie - headers already sent This is the code: if(isset($_COOKIE["cartId"])) { return $_COOKIE["cartId"]; } else { session_start(); session_register("cartId", session_id(), time() + ((3600 * 24) * 30)); return session_id(); } If I remove the session_start() and session_register it works fine, but then everyone uses the same cart and that can't be good. Thanx!!! Regards Tore -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#168225) next »