2011-09-15 199 views
1

我在一個codeigniter會話中存儲$lightopenid->identity,如下所示:LightOpenID - 如何從存儲的會話中檢索電子郵件?

   $lightopenid   = new Lightopenid; 
      $lightopenid->required = array('contact/email'); 

      if ($lightopenid->validate()) { 

       $google_open_id = $lightopenid->identity; 
       $this->session->set_userdata('google_open_id', $google_open_id); 
      } 

在我的控制器的一個單獨的函數中,我想檢索用戶的電子郵件。

   print_r($this->session->userdata('google_open_id')); 

會顯示身份鏈接,但如何從中檢索電子郵件?

我需要lightopenid的新實例嗎?

有什麼建議嗎?

+0

看看[這裏](http://stackoverflow.com/questions/3995011/log-in-the-user-with-lightopenid/3999068#3999068) – tttony

+0

ttony和@jeff - 我在發佈之前就已經看到了這個問題,但仍然不認爲我的是一個騙局 - 你鏈接到的問題沒有解決需要通過codeigniter會話檢索電子郵件***的問題,在控制器中這不是Lightopenid對象創建的*** *** – pepe

回答

0

您必須在會話中存儲電子郵件。 LightOpenID不存儲任何內容。您必須重新進行整個身份驗證才能僅從身份中檢索電子郵件地址。

所以,這樣的事情:

if($openid->validate()) { 
    $attributes = $openid->getAttributes(); 
    $this->session->set_userdata('open_id', $openid->identity); 
    $this->session->set_userdata('email', $attributes['email']); 
} 
相關問題