Re: [PHP] Session for creating a unique shopping cart for each user

From: Tore E. Mackay (tore_at_temweb.net)
Date: 10/31/03


To: php-general@lists.php.net
Date: Fri, 31 Oct 2003 16:06:22 +0100

Don't realy know.

Here is what I have:
1. An index.php that inculdes products.php if $file=products.php.
2. products.php includes db.php that contains databse connection and the
code for creating a session.
3. When I click "add product" $file=cart.php and cart.php includes the
db.php file that should connect me to the db and check if there is a
session.

It works fine if I go passed the index.php file. Maybe it is because the
index.php file has echoed information. Any idea????

Tore

"Gareth Williams" <gareth@venditor.com> skrev i melding
news:5C845C18-0BB1-11D8-9384-000A956BB5B4@venditor.com...
> 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
> >



Relevant Pages

  • Re: [PHP] Session for creating a unique shopping cart for each user
    ... 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 ... > I am creating a shopping cart but experiensing some difficulty in ...
    (php.general)
  • Re: [PHP] Session for creating a unique shopping cart for each user
    ... why use a cookie - the $_SESSION is itself a cookie ... > code for creating a session. ... Once the first echo has ... >>been performed, you can't send header information, as the header is ...
    (php.general)
  • Re: [PHP] Session for creating a unique shopping cart for each user
    ... Do you see any information in your browser before the error appears? ... > code for creating a session. ... Once the first echo ... >> been performed, you can't send header information, as the header is ...
    (php.general)
  • four or five shopping cart design questions
    ... I'm thinking about building a shopping cart from scratch, ... How does repeat customer session handling usually work? ... they have to supply name address and credit card number. ... the shoppingMode screens, do we NULL out the credit card in ...
    (comp.lang.php)
  • SessionID Still not working
    ... I have written a shopping cart using ASP .NET. ... The session ID is supposed to stay the same!!! ... IIS 6.0 W2K3 server and updated patches. ... that displays the sessionid on the top of the page, and it changes when I hit ...
    (microsoft.public.dotnet.framework.aspnet)