title: how to manage a simple cart session in symfony 2?
body: <p>im trying to make a simple cart in symfony2, but the documentation about session is very limited and the only example i have found are about user.</p>
  
  <p>from what i understand in watching videos is that have to make this steps:</p>
  
  <p>1-make sure to have a session array, if not declare a new session array
  2-add variables to the session array via array_push();
  3-display session </p>
  
  <p>this is my code so far:</p>
  
  <pre><code>public function sessiontestAction(Request $request)
  {  
  
  $session = $request-&gt;getSession();
  if(!$session)
  {
     $session-&gt;set('producto');  
  }
  
   $em = $this-&gt;getDoctrine()-&gt;getManager();
    $producto = $em-&gt;getRepository('savaInventarioBundle:TblProductos')-&gt;find(29);
  
       if(!$producto){
           throw $this-&gt;createNotFoundException('no se encontro el producto');
       }
  
       array_push($session, $producto);
  
    return $this-&gt;render('savaInventarioBundle:Catalogo:sessiontest.html.twig',
             array('productos'=&gt; $session));
  }
  </code></pre>
  
  <p>my output just throws 1 product instead more then one every time i invoke the function, also it shows this error "Warning: array_push() expects parameter 1 to be array, object given i"</p>