请帮我猜猜这个混合身份验证代码


Please help me guess this hybridAuth code

有人可以帮我猜出这段代码吗?这只是一个片段,我想我包含了我的问题所需的所有代码。实际上,此代码来自混合身份验证。我的问题是,最后一行的"user_id"从何而来?我想知道,因为 $_SESSION["用户"] 给出了"id"的值。我想再赚 $_SESSION[" "],我可以在其中放置数据库中电子邮件添加的值(与该user_id的"id"所在的位置相同)

// create an instance for Hybridauth with the configuration file path as parameter
$hybridauth = new Hybrid_Auth( $hybridauth_config );
// try to authenticate the selected $provider
$adapter = $hybridauth->authenticate( $provider );
// grab the user profile
$user_profile = $adapter->getUserProfile();
// load user and authentication models, we will need them...
$authentication = $this->loadModel( "authentication" );
$user = $this->loadModel( "user" );
# 1 - check if user already have authenticated using this provider before
$authentication_info = $authentication->find_by_provider_uid( $provider, $user_profile->identifier );
# 2 - if authentication exists in the database, then we set the user as connected and redirect him to his profile page
if( $authentication_info ){
// 2.1 - store user_id in session
$_SESSION["user"] = $authentication_info["user_id"]; 

$authentication->find_by_provider_uid() 的调用返回一个关联数组,其中一个键是 user_id

若要查看该调用返回的其他列,请执行以下操作:

var_dump($authentication_info);

如果email在该数组中的键中,则可以将其设置为$_SESSION

// Store the email into session if it is present in $authentication_info
// Use whatever the appropriate key you find, be it email, email_address, user_email, whatever...
$_SESSION['user_email'] = $authentication_info['email'];