1

I have situation where i want to store my whole cart into cookie so that if accidently user closed browser, cart contains the same contents using that cookie.

Right now, i am using codeigniter cart class to contain all the products user added to cart.

//array for product details...
$insert_data = array(
  'id' => $this->input->post('id'),
  'name' => $this->input->post('name'),
        'price' => $this->input->post('price'),
  'image' => $this->input->post('image'),
        'qty' => 1
);

//add previously defined data to cart....
$this->cart->insert($insert_data);

//assigning whole cart to cookie
$this->input->set_cookie('cart_cookie', $this->cart->contents(),36000);

But here, set_cookie method is giving error as it is expecting second parameter to be string...But i want whole cart to be stored..

Any solution with this problem? Or is there any better solution than cookie?

Red
  • 2,728
  • 1
  • 20
  • 22
  • http://stackoverflow.com/questions/6705487/how-codeigniter-keeps-session-data-even-when-browser-closes http://stackoverflow.com/questions/14359806/why-the-codeigniter-session-does-not-expire-after-closing-the-browser – Jackson Sep 09 '16 at 07:03
  • `serialize($this->cart->contents())` – cske Sep 09 '16 at 07:09

0 Answers0