I want to add product to my session array but always it overwriting existing product and is only one.
/**
* @Route("/{id}", name="add", methods={"GET"})
*/
public function add(Product $product, Request $request): Response
{
$session= $request->getSession();
$session->set('products', array(
'list' => $product,
));
$this->addFlash('success', 'add');
return $this->render('index.html.twig', [
'product' => $product
]);
}
any suggestion?
Source: Symfony Questions
Was this helpful?
0 / 0