Actually, I am creating a shopping cart. I need to store the product_id and the quantity in the session, so that I can retrieve these into the Cart page.
Currently, I am adding values to the session variable using the push method-
$request->session()->push('order.products', $request->product_id);
It stores data in this structure-
array (size=1)
'products' =>
array (size=2)
0 => string '11' (length=2)
1 => string '9' (length=1)
But, in this way I am not able to store the quantity. I think storing associative array into the session can solve my problem.
So, how can I do that??