有人可以幫我猜這個代碼..這只是一個片段,我想我包括了我的問題所需的所有代碼。其實這個代碼來自hybridAuth。我的問題是,最後一行的「user_id」來自哪裏?我想知道,因爲$ _SESSION [「user」]給出了「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"];
@邁克爾,如果我輸入var_dump($ authentication_info)將顯示在監視器上?不需要回聲? – 2012-08-14 12:40:32
我將它擴展爲下面的答案。不需要echo - ['var_dump()'](http://php.net/manual/en/function.var-dump.php)是一個調試函數,它將顯示數組或對象的內容。不用於真正的顯示輸出,僅用於調試和可視化。 – 2012-08-14 12:42:23