laravelshoppingcart icon indicating copy to clipboard operation
laravelshoppingcart copied to clipboard

Cart clears when logging out

Open Stelikas opened this issue 3 years ago • 0 comments

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.

Stelikas avatar Jun 18 '22 17:06 Stelikas