laravelshoppingcart
laravelshoppingcart copied to clipboard
Cart clears when logging out
I have created this function inside CartController
private $cart_id;
public function __construct()
{
$this->cart_id = \Cookie::get('cart');
if ($this->cart_id) {
} else {
$this->cart_id = uniqid();
$this->setCartCookie();
}
}
public function setCartCookie()
{
if (!Cookie::hasQueued('cart')) {
Cookie::queue(
Cookie::make('cart', $this->cart_id, 60 * 24 * 30)
);
}
}
Although when logging out the cart is empty but the cookie still remains the same.