Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts

    Using cookies in a shopping cart

    I am about to develop a shopping cart system, however i am wondering what is the advantage of using cookies over sessions. In the past I have generally tried to avoid using cookies some ppl turn them off and I dont like cookies. I always turn off any auto complete or remember this options on my browsers. I understand generally developers use cookies for a shopping cart systems however i was wondering weather i could pass the cart information through php's super duper session vars. Of course I know this could work but what will be the disadvantages and generally why do developers use cookies

  • #2
    4xz
    4xz is offline
    Regular Coder
    Join Date
    Aug 2004
    Location
    localhost
    Posts
    163
    Thanks
    0
    Thanked 1 Time in 1 Post
    Well, sessions use cookies too in most cases, so not much of a difference there. You could save the cartinfo to the database linking it to a specific session, but it would only save data in the cookie, not the cookie itsself.

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Thanks, I will have to use cookies then. I will make it a something that users need in order to use the shoping cart feature. I can easily test by setting the cookie and testing to see if it was set. If not an "Please enable cookies" error message. If I were to use sessions then i presume I would need to ensure that the session ID stayed the same. I think I will just use standard cookies and just store a cart ID to refrence a file on the server that stores there information. I am trying to save the client some money by not introducing a whole mmbers section. Anyway all I need is an paypal system so I may find something ready made for this, that will handle all this.

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Just in case you're not aware of this, you cannot set a cookie in PHP and then immediately test to see if that cookie got set. The page has to cycle back to the browser before the cookie actually gets set. You could use Javascript's cookie functions to test this, however. Of course, you'll also need to test to see if Javascript is enabled.

    I'd actually recommend sessions, just for their ease of use. Sessions (for the most part) take care of their ID for you; you don't really have to think about it.

  • #5
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    846
    Thanks
    15
    Thanked 10 Times in 10 Posts
    I am building a shopping cart and I am using sessions because of their ease of use and no one can shut them off via their browser.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #6
    4xz
    4xz is offline
    Regular Coder
    Join Date
    Aug 2004
    Location
    localhost
    Posts
    163
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by dniwebdesign
    I am building a shopping cart and I am using sessions because of their ease of use and no one can shut them off via their browser.

    Sessions can be shut of in the same way cookies are, right ? Opening a session creates a session cookie on the client. Or am I missing something ?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •