echo user in view from sessions code igniter

半城伤御伤魂 提交于 2019-12-02 12:43:38
$username = $this->session->userdata('username');

//Pass it in an array to your view like
$data['username']=$username;   
$this->load->view('test',$data);

//Then in you view you can display it as:
 echo $username;

controller file $data = array( 'username' => $result->name, );

view file

           <?php echo $this->session->userdata('username')?> 

Just store the user name in the userdata (you've already done this!)

$this->session->set_userdata('username') = 'John Doe';

And retrieve it just like that

$username = $this->session->userdata('username');
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!