So how does the script no what to do for the first cookie, if there is no data in the "first" cookie to recieve? Does it create a cookie though there is specification for it? We set the expire date to close when the browser closes (expire field left out for a default setting). This is where we are confused, where does the first cookie come from when you click a purchase and send the data to the script when the order the script will process it does not seem right? | [reply] |
If there is no cookie, there are no previous purchases. Adding the new purchases to nothing yields a combined purchase that consists only of the new purchase. That gets saved. If the user keeps adding more purchases without closing the browser, the next thing they purchase will get added to that original purchase because there is now something in the cookie (the first purchase). If, however, they close the browser and then re-open it and come back and make a second purchase, the cookie will have expired and their first purchase forgotten. That's the desired behaviour - remember the shopping basket for the current browser session and forget it when the current browser session closes. That way the cookie keeps a running total of all purchases in the current session but does not keep anything between sessions.
| [reply] |