【发布时间】:2014-06-17 19:55:56
【问题描述】:
使用来自 here 的相当标准的 PHP 安全模型
每个页面都有一个如下所示的会话再生功能和一个 login_check 功能(参见上面的 url)。
function sec_session_start() {
$session_name = 'sec_session_id'; // Set a custom session name
$secure = false; // Set to true if using https.
$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.
$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
session_regenerate_id(); // regenerated the session, delete the old one.
}
如果我的用户线路慢并且请求页面太快,他们就会遇到问题 - 他们被抛出并返回登录页面。我认为这可能与会话再生有关。有什么想法吗?
【问题讨论】:
-
不太确定这有什么安全性! ID 重新生成是有代价的,因此您可能需要重新考虑重新生成 ID 的频率。
标签: php session session-state login-script