title: Store objects in sessions Symfony 2
body: <p>I am writing a small e-shop application with Symfony 2 and I need some way to store the user's shopping cart in a session. I think using a database is not a good idea.</p>
  
  <p>The application will use entities like <strong>Product</strong>, <strong>Category</strong>, <strong>ShoppingCart</strong> where Product and Category are persisted into the database and users will be choosing products into their ShoppingCart.</p>
  
  <p>I have found <strong>NativeSessionStorage</strong> class which is supposed to save an entity into a session. But there is no written process of implementation into an application.</p>
  
  <p>Do I use this in the controller or in a separated class ShoppingCart? Could you give me a short example of <code>NativeSessionStorage</code> usage?</p>
  
  <p><strong>EDIT:</strong>
  The question was not set correctly:</p>
  
  <p>The goal is not to save all product ids into a cookie. The goal is to save only a reference for basket (filled with products) in application memory on server-side and assign proper basket to user. Is this even possible to do this in PHP?</p>
  
  <p><strong>EDIT2</strong>:</p>
  
  <p>Is a better solution to use a service?</p>