title: Meteor JS: Shopping Cart Without Login - session id, etc
body: <p>I'm working on a e-commerce project.
  I would like the customers of the e-commerce site to be able to add items to the shopping cart and checkout without having to login.</p>
  
  <p>To do this, I have decided to store the items that the customers would like to add to the shopping cart inside a Collection.
  e.g.</p>
  
  <pre><code>CartItems = new Mongo.Collection("cartitems");
  </code></pre>
  
  <p>In order to differentiate this customer's shopping cart items from other customers, I have decided to add a extra field</p>
  
  <pre><code> var sessid = Meteor.default_connection._lastSessionId;
  </code></pre>
  
  <p>e.g.</p>
  
  <pre><code>{
      "_id" : "HCo7JYsaruYBNQuC9",
      "qty" : 1,
      "productid" : "hAajzGxpLK4zJ3pXW",
      "session" : "uqTiaeqiawsxLMu7A"
  }
  </code></pre>
  
  <p>to the document added to the CartItems collection.</p>
  
  <p>The problem with this solution is that whenever the page is REFRESHED, the last session Id changes and therefore the cart becomes empty again even though the same user is still using the page.</p>
  
  <p>Also, the documents added to the Collection does not get cleaned up (deleted) as I have no way of detecting if the session is going to be ended by the browser/user.</p>
  
  <p>1.) What's the ideal solution to this problem?</p>
  
  <p>2.) How do I implement the shopping cart for it to know that even though the page has been refreshed the user using the site is most likely the same person and therefore it should still keep the same items in the shopping cart? 
  With my current solution of using session ids to differentiate one cart item from another seems to be not the suitable solution for this...</p>
  
  <p>3.)  With my current solution of using last session ids, the Collection will eventually be full of cart items with session ids from the past and I would like to provide a automatic clean-up functionality within the app for this.  What's the best way to do this clean-up?
  Is there a way to detect an 'end of session'?</p>
  
  <p>Thank you very much.</p>