使用PHP的用户认证数据库和IP地址? [英] PHP user authentication using database and ip address?
问题描述
我一直在考虑用户认证而产生的,使用会话/饼干和拿出会话劫持的安全隐患的问题。据我所知,使用安全https://开头是最有效的方法,以及regenerate_session_id()和使用验证一个随机字符串(在众多的附加程序)
I have been considering the problems arising with user authentication, using sessions/cookies and the security risks that come up with session hijacking. I understand that using a secure https:// is the most effective method, as well as regenerate_session_id() and using a random string for validation (amongst numerous additional procedures).
我的问题是:有没有把这项内放弃会话和饼干的方法的可能性,并且只使用数据库中保存的变量
My question is this: is there a possibility to incorporate a method that forgoes sessions and cookies, and uses just database held variables?
下面是我将如何设置它:
Here is how I would set it up:
- 具备在用户表中的列,可容纳一个IP地址,一个这将是一个布尔值。
<强> - 当用户在登录',设置用户到数据库的当前IP地址,并设置布尔值到假(如果用户不希望被'记起')或真(如果他们这样做)。
<强> -On页负载,它检查与存储在用户数据库中的一个当前IP地址。如果匹配,用户被认为是有效的。
-On窗口关闭,该脚本会再清除这些值,用户是'退出'。
- 如果用户希望保持登录状态(这是我所知道的是一个巨大的安全隐患),然后切换(布尔值)只会停用注销脚本和IP地址将保持存储该用户。
会是什么回退,以这样的方法?它甚至有可能?
What would be the fallbacks to such a method? Is it even possible?
推荐答案
IP地址根本就不是一个准确而可靠的方法来唯一地标识一个用户。该IP可以在会话期间更改,而且不止一个用户代理可以使用相同的出站IP。
IP addresses are simply not an accurate and reliable way to uniquely identify a user. The IP may change during the session, and more than one user agent may be using the same outbound IP.
抱歉: - )
这篇关于使用PHP的用户认证数据库和IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!