I am using the following piece of code one two difference PCs
mt_srand($_GET['random_number']);
for ($i = 0; $i < 50; $i++) {
$random_number = mt_rand();
$predicted_token = $random_number;
echo "Predicted magic link token: " . $predicted_token . "<br>";
}
mt_srand($_GET['random_number']);
for ($i = 0; $i < 50; $i++) {
$random_number = mt_rand();
$predicted_token = $random_number;
echo "Predicted magic link token: " . $predicted_token . "<br>";
The above code is generating completely identical list on both PCs using the random_number value as 1111.
Now on one of the PC, if I stop my Apache2 and start it again (so that I can reset the whole process). I have the following code to send reset password email.
if (!isset($_SESSION['seed_set'])) {
mt_srand("1111");
$_SESSION['seed_set'] = "valid";
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
...
...
try {
// Connect to SQLite database
$db = new PDO('sqlite:users.db');
if ($user) {
$random_number = mt_rand();
The issue is that when I use this approach to get the random number, it is completely different. and not part of the list that i generated above. The only different thing I am doing here is that I am seeding only once, so that I should have one identical list. What is the issue here?
5