Store shopper's items


When you want to capture items that a person wants to buy on your website, but they do not have an account yet, what is the best way to do that?


Store them in a session, use a cookie.

The session is the preferred way to handle this however.


How do you associate a session with a visitor?


You don’t have to, the server will do it for you.

Try a test out.


Does a session have an ID or something?

If so, is there a way to grab that?



How do websites usually implement shopping carts?

Do they use a PHP session? Something else?


They do them a variety of ways, but sessions are typically used, as are cookies. You could always install some of the ecomm software and see how they do it.


So here is the problem I am trying to solve…

I am building a modest ecommerce site where people can buy a paid subscription for access to premium content.

I had a really sweet process flow all built out, but then after talking with others and reading up on things, it seems my process was too involved and that causes people to ditch their checkouts?!

So now I am back at my drawing board.

Now I am trying to build a streamlined checkout where you choose a subscription and enter account credentials and payment details all in one swoop.

But that creates a problem because I can store sopping cart items in the Member record in the database.



Here is the scenrio where I’m not sure what to do…

There are 3 subscriptions. The un-registered user chooses “Plan-C” which includes a free book.

Because there are many books, I have to route them to my product catalog where they can browser, choose their free book, and then I need to bring them back to my one-stop-shop checkout page.

Follow me?

So I wasn’t sure how to keep track that they chose “Plan-C” and a free book entitled “Dummies Guide to Blah”.

(With my old design, all of this would have been stored in the database.)


Have you looked at existing ecommerce software? They do digital content and all


What does that have to do with anything?

I described a process flow and asked how to best handle it.


So you would store the selections in a session until the complete the transaction. Just make sure you verify the inputs before you commit anything


Let’s walk through an example…

An unregistered guest decides he/she wants access to premium content and clicks on “Subscrible” on the home page. The user is taken to a page showing a couple of different member plans. The user clicks on the “Premium+” plan, and I would store that in the session, right?

Then the user is taken to my product catalog where they are asked to choose a free eBook as part of the “Premium+” plan. So they choose “eBook 1234” and I would store that in the session too, right?

Then the user is taken to a checkout page. The uesr can click on an “Edit Choices” button which takes the user back to the second page where the user can change which member plan he/she wants. And if the user chooses the “Premium+” plan, he/she is taken next to the product catalog where he/she can choose a different eBook (e.g. “eBook 5678”) at which point the user is brought back to the checkout page. During all of this the session is keeping track of this unregistered (basically anonymous) users and the subscription chosen as well as possibly which free eBook was chosen, right?

Once the user is on the checkout page, I ask the user to enter in account details (e.g. username, email, password) and payment details and once the user clicks on “Process Order” then I create a record in the database and now I no longer need to use the session.

How does all of that sound?

And will a session help me to ccomplish that?

Also, if the user closes their browser window then I lose whatever they selected, right?


I’ll work on getting a test set up for you to try out…


Thank you for offering to create a sample, but can you also please comment on my wirte up in the last post and answer my questions as well?



Correct, but I would have them go further through the process. But, yes, each step would get saved to the session data.


Right. And if an update is made, the previous data is overridden. After all, you would need to store what choices they made in order to allow them to edit their choices, correct?

Also correct. When you successfully save their data to a long time store, you can get rid of the temporary storage of that data.

If you want longer term storage, you can use cookies with a lifetime setting. That would be more persistent than a session, just be careful you set the values, to prevent tampering.



Okay, thanks for the responses. It sounds like I am on the right track. Now I just need to find some time to sit down and write out the code. (First I have to remember how to do the HTML and CSS part?!)

I may be back later with specific coding questions, but am feeling a little more confident now.



Don’t just start writing code, write out a plan of what should happen, how it should happen, and what needs to get done. Then start coding.


I have already done this. I sketched out a storyboard for the entire process. Now I just need to refine it and then hope to start coding this weekend.

Good advice, though.