Online Shopping Cart Question...
Posted: Wed Jul 20, 2005 9:42 am
Which is best to use for an online shopping cart?
1. Sessions
2. Cookies
???
1. Sessions
2. Cookies
???
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
There's no such thing as "proper memory session". There's no magic to sessions, it sends the session ID to the browser in one of two ways: either by cookie or via the get query string (or hidden variables in post, etc).onion2k wrote:Sessions can degrade to _GET session ids if the user hasn't got the capability to use proper memory sessions. I think that's a good reason to use them.
I was thinking of sessions, but what happens if the user accidentally closes the browser after ordering 2871 differnet items ?nielsene wrote:It depends.
I would probably say Sessions, 9 times out of 10. However, if you want the shopping cart to persist between browser close and re-opens, you'll need to use cookies in addition.
In IE you can switch off textfile based cookies and yet retain the ability to use session cookies that are held in memory. PHP sessions will still work if the user has memory cookies switched on. Which is what I meant.nielsene wrote:There's no such thing as "proper memory session". There's no magic to sessions, it sends the session ID to the browser in one of two ways: either by cookie or via the get query string (or hidden variables in post, etc).onion2k wrote:Sessions can degrade to _GET session ids if the user hasn't got the capability to use proper memory sessions. I think that's a good reason to use them.
So its more proper to say "Session can degrade to _GET session ids, if the user can't/doesn't accept cookies."
Then the user would lose their shoping cart. For most on-line shops, users aren't putting more than may 10-30 items in their cart, and most users don't acccidently close their browser while shopping. Therefore your concern isn't too common. Shops are also used to a very high percentage of "abandoned" carts -- ie populated carts that never get checked out (ie browser closed, person leaves the site, etc). Many site encourage this behavvoir by only showing you prices/discounts if you add an item to your cart (*cough* amazon *cough* ("This item's price is too low, please add to your cart to see it"... for a several thousand dollar computer))Dale wrote:I was thinking of sessions, but what happens if the user accidentally closes the browser after ordering 2871 differnet items ?nielsene wrote:It depends.
I would probably say Sessions, 9 times out of 10. However, if you want the shopping cart to persist between browser close and re-opens, you'll need to use cookies in addition.