I’m writing a simple shopping cart application and have hit a road block. Currently my shopping cart application associates the shopping cart (in the DB) with the user’s id on the site, but I want to allow visitors to add items to the cart as well.
I asked this question a while back on stackoverflow and the one answer I got was “use sessions.” However, after reading about sessions, it appears that the session variables are destroyed when the user closes their browser, and on top of that there is a time limit to how long they can last. Additionally, I read that having lots of session variables can “bog down” the server.
So now I’m back to square one. Should I use session variables to keep track of visitors who want to add things to their cart (I would like a visitors cart to remain available to them for a few weeks)? I also thought of using their IP address, but I know that that changes depending on where they are connecting to the internet (if using a laptop).
What do you recommend?
you could also use cookie’s which stay for a certain amount(if user allows cookie to be accepted)