Javascript - remove part of cookie with a split('|') like array
        Posted  
        
            by MgS
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by MgS
        
        
        
        Published on 2010-06-07T15:44:26Z
        Indexed on 
            2010/06/07
            15:52 UTC
        
        
        Read the original article
        Hit count: 266
        
I'm abit stuck.
I'm using jQuery.
I have a cookie which has the value such as :
1,something|2,somethingg|1,something
We are treating it as [0] as id and [1] as name.
I need to remove ONE where the id == '1' for example, this will leave the cookie like this:
1,something|2,somethingg
How do I go about this, it will probally be in a loop, but not sure how to remove one of them. I have this so far:
function removeItem(id){ 
var cookieName = 'myCookie';
 var cookie = $.cookie(cookieName);
 if(cookie){
  var cookie = cookie.split('|');
  $(cookie).each(function(index){
   var thisCookieData = this.split(',');
   if(thisCookieData[0] == id ){
   }
  });
}
        © Stack Overflow or respective owner