Symfony cookies issue


hey everyone am trying to add an element inside a the browser cookie and am getting this error :   Notice: unserialize(): Error at offset 667 of 669 bytes

this is my function to list the cart stored in the cookies :

public function CartViewAction(Request $request)  {   $cookies=$request->cookies;   $cookie= unserialize($cookies->get('panierproduits'));   return $this->render('@Home/SafaViews/cartsidebard.html.twig' array(   'cart' => $cookie   ));  }  

and this is the add product in cart function :

public function addAction(Request $request $id)  {   $produit=$this->getDoctrine()->getManager()->getRepository('DatabaseBundle:Produit')->find($id);   $cookies=$request->cookies;   //Done   //if notre cookie est false ecrire Votre cart est empty   $notrecookie= unserialize($cookies->get('panierproduits'));   $qte=0;   foreach ($notrecookie as $key=>$value)   {   if ($value->getIdproduit()==$produit->getIdproduit())   {   $qte=$qte+1;   }   }   if ($produit->getQuantite()<=$qte)   {   }   else   {   $lastKey=0;   foreach ($notrecookie as $key=>$value)   {   $lastKey=$key;   }
$cookie_info = array(   'name' => 'panierproduits'