by nodesocket · 11y ago · 0 comments
$id = Functions::generate_random(5) . uniqid() . Functions::generate_random(3);
`uniqid()` ensures each id is unique (somewhat), and the random paddings of 5 and 3 characters make the ids harder to guess and unpredictable.Then use the option for more entropy in case the function is called more than one in a milliseconds.
So in total:
uniqid(gethostname().getmypid(), true);
Will be unique if you give sane names to your machines.