title: How can I add multiple values to a Symfony session as an array?
body: <p>I'm trying to create a basic 'add to basket' functionality in Syfmony using Ajax. So far I have this:</p>
  
  <pre><code>/**
   * @Route("/basket/add")
   */
  public function addAction(Request $request)
  {
      $item = [
          'id'     =&gt; $request-&gt;get('id'),
          'artist' =&gt; $request-&gt;get('artist'),
          'title'  =&gt; $request-&gt;get('title'),
          'type'   =&gt; $request-&gt;get('type')
      ];
  
      $this-&gt;session-&gt;set('basket-'.$item['id'], $item);
  
      return new JsonResponse($this-&gt;session-&gt;all());
  }
  </code></pre>
  
  <p>But ideally I'd have one session set for the basket. I tried previously by trying to use <code>array_push</code> in order to append values one by one, but I didn't get very far. </p>
  
  <p>Any suggestions? </p>
  
  <p>Cheers</p>