the joys of a UTI

How did you prevent UTIs? Did anyone take cranberry supplements, and are they safe?