2016-05-31 133 views
-1

我要去檢查當前用戶ID和獲取信息是男是女,但condn假要登錄後纔可查看登錄會話ID在笨

public function profile() { 
    $this->load->view('header'); 
    $uname = $this->session->userdata('uname'); 
    $row = $this->brid_groom_fetch->get_program_specific_gender(); 
    if ($row['uname']->uname == $uname) { 
     $session_id = $this->session->userdata('session_id'); 
     var_dump($session_id); 
    } else { 
     echo 'fail'; 
    } 
} 
+0

您需要添加一些更多的細節來回答這個問題。控制器方法沒有錯誤。 'brid_groom_fetch'是模型還是圖書館?該方法看起來如何?會議如何設置?你有任何錯誤? – jtheman

+0

我得到會話數據Array([__ci_last_regenerate] => 1464684288 [logged] => 1 [uname] => [email protected] [logged_in] => 1) – sms

+0

和db數據([__ci_last_regenerate] => 1464684288 [登錄] => 1 [uname] => [email protected] [logged_in] => 1)Array([0] => stdClass Object([bride_grum_id] => 1 [name] => admin @ 2016 [膚色] => ssssssss – sms

回答

0

不要使用含有變量的任何數組對象stdClass的只需檢查兩個變種

public function profile() { 
    $this->load->view('header'); 
    //  print_r($uname); 
    if ($this->session->userdata('logged_in')) { 
     //get Data from db 
     $row = $this->brid_groom_fetch->get_program_specific_gender(); 
    //get session Id 
     $uname = $this->session->userdata(); 
     //compare both variable directly don't use array format to compare 
     if ($row = $uname) { 
      $session_id = $this->session->userdata(); 
      var_dump($session_id); 
     } 
    } 
}