What does the PHP manual mean by "Process IDs are not unique"? How do I get the actual unique "process id"?

Source: https://www.php.net/manual/en/function.getmypid.php
Warning Process IDs are not unique, thus they are a weak entropy source. We recommend against relying on pids in security-dependent contexts.
How can a "process id" not be unique? What am I missing? Andgetmyuid()
is equally nonsensical in that it doesn't give any useful process id back, but only:
Gets PHP script owner's UID
In short: How do I get some kind of unique id for the current (CLI) PHP process from where this is run?
Answer
Solution:
PIDs are not unique. If a process dies the OS may reuse the ID for a new one. This is not a PHP thing.
If you want to generate unique values useuniqid()
https://www.php.net/manual/en/function.uniqid.php
If you're on linux you could also useuuidgen
in backtics (``):
var_dump(`uuidgen`);
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: please make sure the php redis extension is installed and enabled.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.