Welcome to WebmasterWorld Guest from 188.8.131.52
I'm trying to make unique IDs for my users, so I'm concatenating their IP address with the time of their first access.
I would imagine this this would give a pretty good unique ID, but then I then I saw an unlikely flaw:
A "unique" id would be given twice if one computer had two first requests at the same time. (ie: If the user has FF and IE opened and accessed the site within the same second)
To remedy this, I decided to concatenate a random number.
That way, in this very unlikely event, there would only be a 1/10000 chance of two equal "unique" IDs.
However, I remembered that rand is only a pseudo random number. I'm thinking that if it's based on time, then that defeats the purpose of adding the random number, since the two times would be the same.
So I'm wondering, how random is rand(), and should I add the random number to the unique IDs?
It's based on Mersenne Twister [math.sci.hiroshima-u.ac.jp]
Moreover the seed is also random, so it would require running both instances synchronized.
Therefore your code should run smoothly.
PS. There's no problem in checking ;)
Why do you need this unique ID, anyway - if you are storing this info in a database, just use a numeric auto increment column as the ID.