title: Setting a new value to a cookie creates a duplicate cookie - jquery cookie
body: <p>I have an issue when i am trying to delete a cookie if i have set it on a different page. Here is the scenario:</p>
  
  <p>I am on my homepage and set a cookie value(by adding a product to my basket), i can delete this while i am on that page.</p>
  
  <p>But when i go on a different page and try to delete the same cookie(product), the cookie is created again with the new value, it does not re-set my current cookie.</p>
  
  <p>I am using this code to add/remove the cookie:</p>
  
  <pre><code>$(".add-basket").click(function(e){
      e.preventDefault();
      var ean = $(this).attr('ean');
      var value = $(this).attr("value");
      var path = $(this).attr("imgpath");
  
      if($.cookie("mycookie")==undefined || $.cookie("mycookie")==""){
          $.cookie("mycookie" , ean + "~" + value + "~" + path);
      } else if($.cookie("mycookie").indexOf(ean) == -1 ){
          $.cookie("mycookie",$.cookie("mycookie") + "|" + ean + "~" + value + "~" + path);
      }
  
  });
  
  $(".remove-basket").click(function(e){
      e.preventDefault();
      var ean = $(this).attr('ean');
      var value = $(this).attr('value');
      var path = $(this).attr("imgpath");
  
      var val = ean + "~" + value + "~" + path; //value to be removed
      if ($.cookie("mycookie") !== undefined) {
          var cookie_val = $.cookie("mycookie");
          if (cookie_val.indexOf(val) !== -1) {
              //check value present in cookie
              var arr = cookie_val.split('|'); //remove spaces and split with |
              var index = arr.indexOf(val);//get index of value to be deleted
              arr.splice(index, 1);  //remove value from array 
              $.cookie("mycookie", arr.join('|')); //convert array to sting using join and set value to cookie
          }
      }
  </code></pre>
  
  <p>Am i missing something?</p>
  
  <p>Please help</p>