[英]Session return an empty response in other functions using Codeigniter 3.1
This code is working fine only in this function but when i get session in other functions then it return an empty response. 这段代码仅在该函数中有效,但是当我在其他函数中获得会话时,它将返回一个空响应。
$id = '123';
$this->session->set_userdata('id','$id');
$get_id = $this->session->userdata('id');
print_r($get_id);
Get data in other function like. 获取其他函数中的数据。
$get_id = $this->session->userdata('id');
print_r($get_id);
which is return an empty response. 这将返回一个空响应。
If anyone has any suggestions it would be very much apppreciated! 如果有人有任何建议,将不胜感激!
Thank you 谢谢
Nearly, try this. 几乎可以尝试一下。
$id = array( '123' ); <-------
$this->session->set_userdata( 'id', $id ); <--------
$get_id = $this->session->userdata('id');
print_r($get_id);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.