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

From: Gareth Williams (gareth_at_venditor.com)
Date: 10/31/03


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


Do you see any information in your browser before the error appears?
Perhaps you could also do a view source from the browser to see if
anything has been sent out.

On Friday, Oct 31, 2003, at 16:06 Europe/Amsterdam, Tore E. Mackay
wrote:

> 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
>>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



Relevant Pages

  • Re: ASP sessionstate
    ... ASP doesn't know or care what browser it ... ticket number given when the first item is added to the cart. ... How can a Response.Write write to the server screen? ... :> delete the cart file and set the session ...
    (microsoft.public.inetserver.asp.general)
  • "Compaq Web Agent" management session can be re-used without the need to perform authentic
    ... destructive actions (as server reboot). ... Compaq Web Agent Service 6.0.0.0 using Compaq HTTP Server 5.1.0 on ... servers via a secured HTTP session from a browser client, ... via a legitimate authenticated SSL session - if he closes the session by ...
    (Bugtraq)
  • Re: Attempt to de-mystify AJAX
    ... >>maintaining a session via URL is not a problem. ... >> around cookies and JS, but it seems to be tough. ... >> as needed back to the server. ... but as I mentioned before - a non-dynamic request by the browser can ...
    (comp.databases.pick)
  • Re: Problem with a session
    ... Your first posting was a bit vague, but now I understand your problem. ... the POSTDATA and sets againg the session variable to true and anyone ... This IS a real problem, and you cannot 100% solve it. ... try to tell the browser NOT to chache it. ...
    (comp.lang.php)
  • Re: php session without cookie useage
    ... >>> browser or the application to maintain the state if needed. ... >>> transfer a session key created on login to subsequent pages via a POST ... >>> browser via a cookie or via POST or GET. ... > That may block legitimate users using a round-robin proxy (different ...
    (comp.lang.php)