I am trying to remove a particular value from a cookie on a click event. My code sofar:
            $("a.js-delete-hotel").on("click", function (e) {
            e.preventDefault();                
            deleteHotelId =  $(this).attr("id");
                hotelIdsArray = $.cookie('hotel-comparison').split(/,/);
                if($.inArray(deleteHotelId, $.cookie('hotel-comparison').split(/,/))){
                    for(var i = hotelIdsArray.length-1; i--;){
                            if (hotelIdsArray[i] === deleteHotelId) hotelIdsArray.splice(i, 1);
                    }
                }
                $.cookie('hotel-comparison', hotelIdsArray);
        }); 
This code doesn't work. It creates another cookie with the same name and value.
 
     
     
     
    