【发布时间】:2014-06-28 02:40:59
【问题描述】:
所以基本上我正在重置密码并想设置时间限制。这是我的代码
$time = time();
$hash = md5($id . $time . "somerandomsalt"); // check this again in activation.php
$link = "activation.php?id=" . $id . "&hash=" . $hash . "&time=" . $time;
这会安全吗?我想做的就是让链接在 1 小时后过期。我也有这个生成令牌的代码(我认为这个代码更安全)。
$rand = openssl_random_pseudo_bytes(16); // take 8 random bytes
$token = substr(sha1($rand), 0, 49);
问题是我不知道该怎么说
http://localhost:8888/forgot/activate.php?token=467e65833fc977767d5b000929d1229fa5eaf309
一定时间后过期。有任何想法吗?
【问题讨论】:
-
您可以在控制器中查看日期时间
-
好吧,一旦我将日期存储在数据库中。我怎样才能知道它的年龄? @ManoloSalsas
-
在你的数据库中记录时间戳...
-
好吧,我基本上是在问如何将时间戳与当前时间进行比较@Fabricator
-
假设日期时间已存储。如果 new Datetime()
标签: php html mysql database pdo