我一直在研究创建安全的 php 会话以在登录脚本中使用一周左右。到目前为止,我还没有找到一个具体的资源来作为我工作的基础,阅读 StackOverflow 我所看到的只是混合的观点和意见。
我决定深入研究并编写一个函数来开始会话。
通过大量阅读和观看 Samy Kamkar 在 Youtube 上的 DEFCON 演示文稿,我对我编写的该系统的第一部分相当有信心和满意。
$session_name = 'sec_session_id'; // Set a custom session name
$secure = false; // Set to true if using https else leave as false
$httponly = true; // This stops javascript being able to access the session id
ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies.
ini_set('session.entropy_file', '/dev/urandom'); // better session id's
ini_set('session.entropy_length', '512'); // and going overkill with entropy length for maximum security
$cookieParams = session_get_cookie_params(); // Gets current cookies params.
session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly);
session_name($session_name); // Sets the session name to the one set above.
session_start(); // Start the php session
为了开发,这将与 SSL 一起使用,它不是......
所以我的问题是我可以在哪里改进这个脚本,我错过了什么,接下来我应该研究什么......