I think they are definitely a deterrent. I can't imagine being a superintendent of a correctional facility anywhere and allowing friends or family members to have free rein, just coming and going as they please and not being checked or searched.
Would it have stopped my son? Probably not, in his case. In a lot of other cases, probably for a great percentage it would have. His view of the whole thing was that the punishment he would get for being caught was less than the punishment he'd get for not bringing it in.