Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generating/ storing account activation code

usually on any website after you register they send you an e-mail with an account activation code, is there somewhere some information/best-practices about this technique ?
like about how do you generate them, how do you store them, do you encode or not these activation codes ?

like image 387
Omu Avatar asked Mar 02 '10 10:03

Omu


1 Answers

Generated an activation code can be as simple as generating a random number with a fixed number of digits.

Personally I do this, then store the generated code in the users table of the database along with the username/password/email etc, so that it can be quickly verified when the link is clicked and your checking code run.

I usually go with a 'long' data type and generate 9-digit random numbers, and store these raw (not encoded) in the database for easy retrieval. Passwords should be encoded, but an activation code is a single-use, throw-away value so no need for any special consideration.

like image 78
Dave Avatar answered Dec 30 '22 19:12

Dave