I am storing $lightopenid->identity
in a codeigniter session as follows:
$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);
}
In a separate function in my controller I would like to retrieve the user's email.
print_r($this->session->userdata('google_open_id'));
will show me the identity link but how do I retrieve the email from it?
Do I need a new instance of lightopenid
?
Any suggestions?
You have to store the email in the session. LightOpenID doesn't store anything. You'd have to redo the whole authentication in order to retrieve the email address only from the identity.
So, something like that:
if($openid->validate()) {
$attributes = $openid->getAttributes();
$this->session->set_userdata('open_id', $openid->identity);
$this->session->set_userdata('email', $attributes['email']);
}