Why would you store a shopping cart in your database? Use a browser cookie for storing the user's shopping cart. That way, no two users could possibly access the same cart. If you want it to delete automatically, you can expire the cookie using a date or some other criteria which you could check. The cart would only be stored in your database when the user places the final order and pays.
Cookies Manual