We sail Holland America and when you register you get a plastic room key which is scanned when you go aboard. Anytime you get off they scan it so they know at all times who is and isn't aboard from the ships passenger registry. I'm sure all cruise lines do the same procedure.