微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php – 在CodeIgniter中设置Session_id

在标准PHP中,我可以通过以下方式设置会话ID:

$my_session_id = $_GET['session_id']; //gets the session ID successfully
session_id($my_session_id);   //sets the session with my session_id
session_start();  //starts session.

我如何对CodeIgniter做同样的事情?我正在努力追随:

$my_session_id = $_GET['session_id']; //gets the session ID successfully
$this->session->userdata('session_id', $my_session_id); //it won't set the session with my id.
print_r($this->session->userdata);

我犯了一些错误吗?请帮助我,因为我浪费了几个小时来解决这个问题.如果CodeIgniter Session类存在问题,我可以使用标准PHP代码启动会话吗?我也尝试将标准代码放在CodeIgniter中,但它仍然没有设置session_id.我还设置了$config [‘sess_match_useragent’] = FALSE;

解决方法:

这是我刚刚在另一个question上建议的黑客攻击.将它放在MY_Session的__construct中(未经测试,不适用于加密)

public function __construct()
{
   if( isset( $_GET['session_id'] ) ) 
        $_COOKIE[ $this->sess_cookie_name ] = $_GET['session_id'];
   // Session Now looks up $_COOKIE[ 'session_id' ] to get the session_id
   parent::__construct()
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐