1

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.

coco
  • 11
  • 3
  • Did you tried `print_r($_SESSION);`? – Indrasinh Bihola Nov 19 '15 at 06:53
  • @IndrasinhBihola Yes, I did. it's like `Array ( [my_Id] => 0 [wp_Id] => 0 )` It has nothing to do with facebook SDK. In our app, when user push login button, session start. – coco Nov 19 '15 at 07:04
  • and I found that when I access new server, new server requests implementation of wp_cron.php in old server... now I'm more confused...is this problem related to DNS things...? – – coco Nov 19 '15 at 07:25
  • Are you able to login in the system using facebook sdk?? – Indrasinh Bihola Nov 19 '15 at 09:09
  • @IndrasinhBihola Yes, I was able to login in the system using facebook SDK **on our OLD SERVER**. so I guess application code is not wrong. The old server and the new server has same domain. I'm doubting it's the cause of problem. now I change the host configuration in my mac `/etc/hosts` when I want to see new server. – coco Nov 19 '15 at 09:27
  • I just want to know that what things are going wrong in a newer system. Did you identified it or not?? What values are stored in session while system is running in old server?? What values are stored in session while system is running in new server?? – Indrasinh Bihola Nov 19 '15 at 11:21
  • is it on the exact same domain? – andyrandy Nov 22 '15 at 11:05
  • @IndrasinhBihola The value stored in session is what is made by our own system and what returns from fb in old server, but in new server, only what is made by our own system is stored in session. – coco Nov 26 '15 at 17:49
  • @luschn Yes, it's exact same domain. – coco Nov 26 '15 at 17:50
  • 1
    Did you tried this : http://stackoverflow.com/a/19323397/3283363, http://stackoverflow.com/a/13278198/3283363 – Indrasinh Bihola Nov 27 '15 at 06:00

0 Answers0