Create a unique random token string in Yii for the users table.
I am working on a Yii application that requires the "users" table to contain a column token, which must be a unique random row based on that user in the table (for example, will never be the same twice).
Can anyone give me some advice on this, or is there already a Yii component / extension / generator for this.
Also - what is the most optimal db column type for this?
+3
source to share
2 answers
I like to use CSecurityManager with generateRandomString()
for this. Please be aware that it generates a string that contains the characters ~ and _
The DB column will be varchar
with the length of your row length.
+2
source to share