[英]Codeigniter : Session_id is empty
I have a probleme in PHP Codeigniter, I'm trying to get the sessions Id, but it returns an empty string, 我在PHP Codeigniter中遇到问题,我正在尝试获取会话ID,但是它返回一个空字符串,
this is my code (ControllerTest.php): 这是我的代码(ControllerTest.php):
class ControllerTest extends CI_Controller
{
public function test(){
echo "session: ".$this->session->userdata('session_id');
}
}
And in autoload.php i have this : 在autoload.php中,我有这个:
$autoload['libraries'] = array('database', 'session');
and in the output, i only get this : session:
在输出中,我只得到以下内容:
session:
EDIT : 编辑:
And when I print the session print_r($this->session->userdata);
当我打印会话
print_r($this->session->userdata);
i get this: 我得到这个:
Array ( [__ci_last_regenerate] => 1441821744 )
And if i try ro access the ip_address like this : 如果我尝试ro像这样访问ip_address:
$this->session->userdata('ip_address');
It also returns an empty string 它还返回一个空字符串
Try this 尝试这个
$session_id = $this->session->userdata('session_id'); $ session_id = $ this-> session-> userdata('session_id');
Try this, 尝试这个,
$this->session->all_userdata(); $ this-> session-> all_userdata();
And returns an associative array like the following: 并返回如下的关联数组:
Array
(
[session_id] => 4a5a5dca22728fb0a84364eeb405b601
[ip_address] => 127.0.0.1
[user_agent] => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7;
[last_activity] => 1303142623
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.