How to make a random code protected page.

Does anybody know of a way to have somebody be given a randomized personal code to access another web page? Like the reset your password codes?