Has anyone every created a shopping cart where only a single string variable was used to store a list of items and their quantities? I need your opinion on whether or not this is a legitimate way to code a shopping cart. No sessions are involved here...
Let me be more specific. I only want to pass a variable that contains a single string: item IDs are separated by semicolons, and the item ID is followed by a comma and quantity desired of each item. Each time an item is added, the ITEM string is passed (containing the current list of shopping cart items), as well as the newID variable, which contains the ID of the item to be added, plus the newQuantity variable, which obviously contains the quantity of the newly-added item.
The add-item script simply appends a semicolon, newID, a comma, and newQuantity to the ITEM variable.
The shopping cart displays the list by using the explode() function (which returns an array). The separator would be the semicolon. Then it would be exploded again using the comma as the separator, and then I would basically create a 2-dimensional array, and use the itemID to access the database and get the current price and description, etc.
Does this seem like a legitimate way to create a shopping cart? One advantage to this way over using sessions could be that the item list would not expire... a customer could bookmark the shopping cart and return at any time.