I’m working on a private message system and I want to assign a unique conversation number so I can Identify if multiple users are taking part to the same conversation. I was thinking to assign the Userid of the person who send the message + microtime() like this:
$conversation_number = md5($_POST['user_id']+microtime());
Would this code originate always a unique number or it may also possible that, accidentally, it generate the same number for the subsequent messages?
I think php
uniqidis sufficientFrom PHP DOC
try
However there are approximately 3.402823669209387e+38 different values in a 32 digit hex value (16^32) in
md5the your odds are phenomenally small that there will be a duplicate all the same