What are the potential security risks of using a specific token in a bookmark link for login purposes in PHP?

Using a specific token in a bookmark link for login purposes in PHP can expose the token in the URL, making it vulnerable to being intercepted or accessed by unauthorized users. To mitigate this security risk, it is recommended to generate a unique token for each login session and store it securely on the server-side. This way, the token remains confidential and cannot be easily accessed by malicious actors.

// Generate a unique token for each login session
$token = bin2hex(random_bytes(16));

// Store the token securely on the server-side (e.g., in a session variable)
$_SESSION['login_token'] = $token;

// Use the token in the login link
echo '<a href="login.php?token=' . $token . '">Login</a>';