我有一个方法,我检查用户名和密码(哈希+盐)是正确的。之后,如果用户已经进行了我的操作:饼干系统 - 安全
if(isset($remember) && $remember == '1') {
setcookie('email', $email, time()+60*60*24*100);
}
else {
setcookie('email', $email, time()+3600);
}
我的问题是关于安全问题。上面的代码是不安全的?它需要像签名一样的东西?
例如:
$user_email = $email;
$hash = sha1(rand(0,500).microtime());
$signature = sha1($hash . $user_email);
$cookie = base64_encode($signature . "-" . $hash . "-" . $user_email);
setcookie('authentication', $cookie);
你觉得呢?
如何检查是否有人登录? – ComFreek
好吧,我只检查cookie是定义(isset)还是空的 – anvd
哦,这是非常不安全的,因为在浏览器中手动设置cookie非常简单! – ComFreek