Online Shopping Cart Question...
Moderator: General Moderators
Online Shopping Cart Question...
Which is best to use for an online shopping cart?
1. Sessions
2. Cookies
???
1. Sessions
2. Cookies
???
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.
Oh, and obviously when people say sessions or cookies in an ecommerce context, we invariably mean to store an id that is used to store cart data in a database .. you wouldn't store cart data in the session or the cookie. Just an id.
Oh, and obviously when people say sessions or cookies in an ecommerce context, we invariably mean to store an id that is used to store cart data in a database .. you wouldn't store cart data in the session or the cookie. Just an id.
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."
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.
For places with bigger shopping carts -- for instance places where you're ordering build-to-order desk/bookshelf, etc systems where you have lots of little components to customize and design, the ability to "save" a shopping cart/configuration is VERY useful. This can be done either via cookies or via the database. e.g. a user can store shopping "trips" into the database and the application can show a list of past trips that the user might want to review/add/delete on next visit.
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
how about using database instead of sessions???
when i first developed a shopping cart in ASP I used database table to store product ids and quantity.
I had an problem with the sessions in the university server.
I can create both with no technical difficulty.
but i want to know which is the efficient and most accepted solution in most e-commerce sites.
when i first developed a shopping cart in ASP I used database table to store product ids and quantity.
I had an problem with the sessions in the university server.
I can create both with no technical difficulty.
but i want to know which is the efficient and most accepted solution in most e-commerce sites.
depends what you want to achieve. If you want something like persistent sessions you will have to have some kind of data storage, i.e. database (obviously) or filesystem (more of an academic choice). You would store the session-data in the database using session_set_save_handler.