UTI prevention

a couple months ago i have gotten the worst uti, i was hospitalized and all. since then i've been paranoid that it's going to happen again. what can i do to prevent another one from happening? i read that cranberry supplements help prevent infection. but does anyone know how accurate they are? any advice helps.