Search code examples
phprandompasswordskeyactivation

How to prevent collisions when generating registration activation keys?


I'm working on a big project's registration system.

After successful signup, the server generates some activation key, adds it to user's row and sends it to user by email. Using some password generator class for this purpose.

The question is (I know that it sounds abstract but I just wonder), how to avoid duplicate pass generation? I mean, is there any chance that in future generator can create the activation key that already exists in db table? Should I check for duplication after key generation?


Solution

  • Try out uniqid().