PHP安全会话在快速页面请求中抛弃用户

时间:2014-06-17 10:40:58

标签: php session session-state login-script

使用 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.     
}

我的用户遇到问题,如果他们处于慢线并且请求页面过快 - 他们会被抛弃并被带回登录页面。我认为它可能是会话重新生成的东西。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我使用同样的,从来没有问题......

检查您是否忘记启动

sec_session_start
某处......

或者你可以有反问题...你在某个地方多次调用该函数