I want to give an ID to a user that opens my website and adds some items to their "shopping cart", even if they aren't signed up to the service. Just add, then proceed to sign up when they want to check out. And if they don't go to checkout after adding stuff, then close their browser, come back 2 days later, I want to retrieve their previous orders from database.
How do I give this ID that is unique to a user and remember it next time they visit?
I assume I need to use cookies, but don't know how exactly?