使链接在 X 分钟后过期

Jay*_*min 2 php email

好的,我正在向用户的电子邮件发送激活电子邮件链接。我的激活链接工作正常,我想让该链接在 X 分钟后过期。这是我的代码:

$base_url='http://172.16.0.60/WebServices/';
$activation=md5($email.time());
email format to HTML
        $mail->Subject = 'Activate Your Account';
        $mail->Body    = 'Hi, <br/> <br/> We need to make sure you are human. Please verify your email and get started using your Website account. <br/> <br/> <a href="'.$base_url.'activation/'.$activation.'">'.$base_url.'activation/'.$activation.'</a>';
Run Code Online (Sandbox Code Playgroud)

现在我的 .htaccess 文件

 RewriteEngine On

    RewriteRule ^activation/([a-zA-Z0-9_-]+)$ activation.php?code=$1
    RewriteRule ^activation/([a-zA-Z0-9_-]+)/$ activation.php?code=$1
Run Code Online (Sandbox Code Playgroud)

现在我怎样才能让我的链接过期呢?我的数据库中没有时间戳字段。

Han*_*nky 5

我的数据库中没有时间戳字段。

然后添加一个。

添加一个字段来记录链接的生成时间,然后您可以立即检查他们访问的时间。当您只需相应地调整设置时,就无需浪费时间尝试思考黑客攻击。