如上所述:是否可以手动重新生成Code Igniter会话?我在PHP会话中寻找类似于session_regenerate_id的东西,这样我就可以在用户进行权限提升时手动调用它。
谢谢,
Lemiant
答案 0 :(得分:8)
CI会每隔x秒自动重新生成会话ID,您可以在配置中设置。
您可以在Session.php中创建一个与sess_update()相同的新函数,但是从顶部&上删除了以下 。该函数重命名为regenerate_id()。
// We only update the session every five minutes by default
if (($this->userdata['last_activity']+$this->sess_time_to_update) >= $this->now)
{
return;
}
这将重新生成会话ID,更新users_activity并保留用户数据。只需通过$ this-> session-> regenerate_id();
来调用它答案 1 :(得分:1)
我知道这是一个老帖子,但我遇到过它,所以其他人也可能。
您还可以执行以下操作,这样您就不必破解核心文件(使得将来可能更容易升级codeigniter):
//Setting this to 0 forces the sess_update method to regenerate on the next call
$this->session->sess_time_to_update=0;
//Call the sess_update method to actually regenerate the session ID
$this->session->sess_update();
相信原来的答案让我走上了这条路,谢谢。