Why do people with cystic fibrosis produce thick mucus?

A genetic defect of the CFTR gene affects how the cells in the body distribute sodium. There are different mutations, but all allow too much sodium to leave the cell. Thus, the mucus in a person with cystic fibrosis loses it's fluidity and becomes very thick.