如何使用PHP将忘记的密码链接限制在一小时内


How to restrict the forgot password link within some hour using PHP

我需要一个帮助。我正在向用户的电子邮件发送一个忘记密码的链接,以重置密码。我需要限制该链接,假设一个小时后(lets say 2 hr)。那个确切的链接将不起作用。我在下面解释我的代码。

$message='<p>You recently requested to reset your password.You can reset password by following the link below.If you no longer need to rest your password ,you can ignore this message.</p></br><p><a href="http://thespesh.com/portal/#/resetPass?m_i='.$encrypt_id.'">Reset my password</a></p>';

以上消息作为消息主体发送给用户。这里有一个链接。我需要在2小时后,确切的链接将无效和不起作用。请帮帮我。

在数据库中存储创建时间戳。然后,在验证令牌时,从数据库中获取当前时间和创建令牌的时间。如果差异大于1小时,则它已过期。否则它仍然是有效的令牌