php unique identifier for clients php unique identifier for clients mysql mysql

php unique identifier for clients


you need to remove the "." (dot) in your function. you are probably using an INT which remove numbers after the dot.

return str_replace('.', '', date('dmYHis').$duration);

and make sure the field is big enough - like varchar(50)

my recommendation will be to simply hash the client id using md5

md5($clientid)

and you have the mysql field as a char(32)


You've already got your solution in your code. The php function uniqid() provides... well, a unique ID. If you want to ensure it's really really really really unique (though it's not necessary), just append time() to the end, like so:

    return uniqid().time();

This would also return letters mixed in with numbers (higher entropy), like this response:

    4eb8895a76edc1320716634