echo user in view from sessions code igniter

前端 未结 3 1106
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 06:53

I am new in codeigniter. I have implemented a simple login system. I want to print out a username on my view page which is stored in sessions. here is my controller

<         


        
3条回答
  •  滥情空心
    2021-01-27 07:40

    $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;
    

提交回复
热议问题