I'm trying to change my project server which has a facebook login function. On an old server, getUser() works fine, but it doesn't work with new server.
OLD SERVER
php 5.4.36
apache 2.4.10
facebook sdk 3.2.3
NEW SERVER
php 5.6.14
nginx 1.8.0
facebook sdk 3.2.3
I just changed servers and didn't change any application code. Here is my function. This works fine on old server, but won't work on the new server.
function getFaceBookUserInfo(&$user){
$config = array('appId' => FACCEBOOK_API_KEY,
'secret' => FACEBOOK_API_SECRET);
$facebook = new Facebook($config);
if ($facebook->getUser()) { //this return 0
try {
$user = $facebook->api('/me', 'GET');
//here logic
I followed the code using the SDK and eventually it broke within the function below.
facebook.php
/**
* {@inheritdoc}
*
* @see BaseFacebook::getPersistentData()
*/
protected function getPersistentData($key, $default = false) {
if (!in_array($key, self::$kSupportedKeys)) {
self::errorLog('Unsupported key passed to getPersistentData.');
return $default;
}
$session_var_name = $this->constructSessionVariableName($key);
return isset($_SESSION[$session_var_name]) ?
$_SESSION[$session_var_name] : $default; //this return $default
}
in this function, $_SESSION[$session_var_name]
doesn't exit, so it returned $default, and eventually getUser() returns 0.
I searched and found very similar questions, but none of the answers fixed this issue.