Update:
对于像一次性 URL 这样的东西,我会采用建议的 GUID 式方法。确保链接的生命周期较短。
对于即时登录,没有真正安全的方法来使用单个 URL。
是的,你可以生成一个几乎不可能猜到的 URL,但这并不能给你带来超级安全性。如果您想记住用户,为什么不使用加密的身份验证 cookie?
您给出的示例是,Google 日历不会仅通过 URL 登录您,您必须先经过身份验证,然后 URL 才有意义。
例如。从我的 Gmail 中点击 google 日历会显示:
除非您首先通过我的身份验证,否则这不会帮助您访问我的帐户。
旧帖子:
您可以使用 PHP 生成 GUIDcom_create_guid http://uk.php.net/com_create_guid并使用它。
在linux上我想你可以使用uuid_创建 http://manpages.unixforum.co.uk/man-pages/unix/freebsd-6.2/3/uuid_create-man-page.html,或者这段代码来自here http://algorytmy.pl/doc/php/function.com-create-guid.php:
<?php
function guid(){
if (function_exists('com_create_guid')){
return com_create_guid();
}else{
mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = chr(123)// "{"
.substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12)
.chr(125);// "}"
return $uuid;
}
}
echo guid();
?>