2016-05-31 106 views
0

我想檢查會議,並獲得當前用戶的信息只有一排我在這裏新plz幫助笨3問題與獲取會話ID

public function profile() { 
     $this->load->view('header'); 
     $this->load->model('brid_groom_fetch'); 
     $this->session->userdata('uname'); 

     //This below line fetch model db data 
     $row = $this->brid_groom_fetch->get_program_specific_gender(); 

     //here i have check data is in session.. 
     $session_id = $this->session->userdata(
     array('uname' => $row->uname)); 
     print_r($sesid); 
    } 

回答

0

你爲什麼不使用基本==操作?

public function __construct() { 

    parent::__construct(); 
    $this->load->model('brid_groom_fetch'); 

    // you need to load session library 
    // Have you loaded ? 
    $this->load->library('session'); 
} 


public function profile() { 

    $this->load->view('header'); 

    // you do not need to load in all method. 
    // we have already loaded in __construct() 
    // $this->load->model('brid_groom_fetch'); 

    // use variable 
    $uname = $this->session->userdata('uname'); 

    //fetch data from db 
    $row = $this->brid_groom_fetch->get_program_specific_gender(); 

    if ($row->uname == $uname) { 
     $session_id = $this->session->userdata('session_id'); 
     var_dump($session_id); 
    } 
} 
+0

感謝快速回復,但爵士的用戶數據已經給出錯誤試圖讓非對象的屬性 – sms

+0

誰能給解決這個quation – sms

0

要設置用戶數據與

$this->session->set_userdata(array('uname' => $yourname)); 

$this->session->set_userdata('uname',$yourname); 

要檢查什麼樣的價值是在你需要使用

$sess_name = $this->session->userdata('uname'); 
print_r($sess_name); 

然後驗證用戶數據設置這是您收到的$ sess_name。 你也可以不設置使用

$this->session->unset_userdata('uname');