title: Laravel - How to change value of key inside Session array
body: <p>So I am building a cart and I am using Session to store data for guest users. Here is how I store the items. </p>
  
  <pre><code>Session::push('cartItems', [
      'product' = &gt; $product,
      'size' = &gt; $request['size'],
      'quantity' = &gt; $request['quantity']
  ]);
  </code></pre>
  
  <p>If a guest user adds an item with the same size it should only add the chosen quantity to the <code>cartItem['quantity']</code>. Here is how I do that:</p>
  
  <pre><code>foreach(Session::get('cartItems') as $cartItem) {
      if ($cartItem['product'] - &gt; id == $product_id) {
          $isNewItem = false;
          if ($cartItem['size'] == $request['size']) {
              $cartItem['quantity'] += (int) $request['quantity'];
          } else {
              Session::push('cartItems', [
                  'product' = &gt; $product,
                  'size' = &gt; $request['size'],
                  'quantity' = &gt; $request['quantity']
              ]);
          }
      }
  }
  </code></pre>
  
  <p>When I try to add a product when a product with the same size already exists in the cart it goes through that part of the code </p>
  
  <pre><code>if ($cartItem['size'] == $request['size']) {
      $cartItem['quantity'] += (int) $request['quantity'];
  }
  </code></pre>
  
  <p>But the quantity of the <code>$cartItem</code> doesn't change at all. How can I change it?</p>