大家好,我的会话有数据 但是我无法显示项目,例如我只想要ID
CreateObject("Shell.Application").Open ("C:\Users\tjb1\Desktop\Export.pdf")
我的代码就是这样
Array ( [__ci_last_regenerate] => 1538534437 [logged_in] => 1 [profile] => stdClass Object (
[id] => 1
[email] => teacher@email.com
[role_id] => 2
[tekteach_login_flag] => 1
[date_registered] => 2018-07-27 16:07:50
[deleted] => 0
[first_name] => Elena
[last_name] => Cruz
[middle_name] => Santos
[gender] => Female
[birthday] => 1970-01-01
[status] => Active
[created_on] => 2018-06-01 05:28:26
[created_by] =>
[modified_on] =>
[modified_by] => 0
[deleted_by] => 0 ) )
答案 0 :(得分:0)
您的print_r显示您的ID(及其朋友)已经存储在一个名为profile的对象中。
因此,我根据显示的内容以及如何读取这些值创建了一个小测试脚本。
//
// Using Objects - most likely from a Database result set
//
// Create the session test data
$profile = (object)array();
$profile->id = 1;
$profile->name = 'Fred';
// Display the full session
$this->session->set_userdata('profile', $profile);
var_dump($this->session->userdata());
$profile = $this->session->userdata('profile');
var_dump($profile);
echo 'userId is ' . $profile->id; // Std Object
echo '<br>';
echo 'userId is ' . $this->session->profile->id; // Magic Method
结果
array (size=2)
'__ci_last_regenerate' => int 1538540690
'profile' =>
object(stdClass)[18]
public 'id' => int 1
public 'name' => string 'Fred' (length=4)
object(stdClass)[18]
public 'id' => int 1
public 'name' => string 'Fred' (length=4)
userId is 1
userId is 1
您当然可以使用print_r()代替var_dump()。我只喜欢var_dump()。
答案 1 :(得分:0)
您正在会话中使用配置文件对象。在下面获取ID
$profile = $this->session->userdata('profile');
$id = $profile->id;
echo $id;