Level 46
Change your session provider to database.
Summer Sale! All accounts are 50% off this week.
here controller:
public function getAddToCart(Request $request,$id)
{
$product = Product::find($id);
$oldCart = Session::has('cart') ? Session::get('cart') : null;
$cart = new Cart($oldCart);
$cart->add($product, $product->id);
$request->session()->put('cart',$cart);
//dd($request->session()->get('cart')); //check the data value flow
return redirect()->back();
}
Please or to participate in this conversation.