我使用Hybridauth社會登錄,並在用戶與Facebook認證,我收到以下錯誤:警告:array_key_exists。如何解決這個警告?
Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /hybridauth/Hybrid/thirdparty/Facebook/base_facebook.php on line 1328
我的猜測(可能是錯的),爲什麼這可能會發生是因爲所使用的參數傳遞以Hybridauth來自瀏覽器網址,並且我有兩頁=寄存器& connected_with = facebook。 Hybridauth只需要第二個...
它實際上驗證,但我想擺脫這個錯誤。爲什麼會發生此警告?有什麼辦法可以隱藏它嗎?
這是一個錯誤的位:
/**
* Get the base domain used for the cookie.
*/
protected function getBaseDomain() {
// The base domain is stored in the metadata cookie if not we fallback
// to the current hostname
$metadata = $this->getMetadataCookie();
if (array_key_exists('base_domain', $metadata) &&
!empty($metadata['base_domain'])) {
return trim($metadata['base_domain'], '.');
}
return $this->getHttpHost();
}
編輯:對不起,這是該代碼的警告來自:
/**
* Destroy the current session
*/
public function destroySession() {
$this->accessToken = null;
$this->signedRequest = null;
$this->user = null;
$this->clearAllPersistentData();
// Javascript sets a cookie that will be used in getSignedRequest that we
// need to clear if we can
$cookie_name = $this->getSignedRequestCookieName();
if (array_key_exists($cookie_name, $_COOKIE)) {
unset($_COOKIE[$cookie_name]);
if (!headers_sent()) {
$base_domain = $this->getBaseDomain();
setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
} else {
// @codeCoverageIgnoreStart
self::errorLog(
'There exists a cookie that we wanted to clear that we couldn\'t '.
'clear because headers was already sent. Make sure to do the first '.
'API call before outputing anything.'
);
// @codeCoverageIgnoreEnd
}
}
}
感謝您的幫助,我不完全瞭解,但是您是否知道爲什麼它仍然可以進行身份驗證?這個警告對我來說會是一個問題嗎? – gray 2013-05-05 09:33:06
謝謝,你指出我在正確的方向..我只是採取了整個if子句:「if(array_key_exists($ cookie_name,$ _COOKIE))」,因爲它也說我們需要清除cookie「如果我們可以「..也許只是繼續前進,並清除它。並且警告已經消失......也許不是最好的解決方案,但警告已經消失 – gray 2013-05-05 09:59:11