I have this function in laravel 5.4 but I get error.
$cart[$product->id] = $quantity;
var_dump($cart);
return redirect('catalogs')->withCookie(cookie()->forever('cart', $cart));
var_dump($cart) contains this:
array(1) { [1]=> string(1) "1" }
Error warning:
Method SymfonyComponentHttpFoundationCookie::__toString() must not throw an exception, caught ErrorException: Array to string conversion
If I passed just string value (not array), it success. If there any way to store array cookie in Laravel?
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…