tags:

views:

192

answers:

2

Iam trying to build an Facebook Application based on PHP. The Application is running under php on my own Webhost inside an Canvas as iFrame.

I have included the newest Client Library for PHP from Facebook: facebook-php-sdk-94fcb13

To Authorize the user inside my application iam trying to use Facebook Connect, like the example shipped with the Client. Everything works fine the 1st Login, but when i hit the F5 Key to reload the page, the session is lost and i have to login again. When i call my application outside of the Facebook Canvas everything is fine.

Iam not sure, but i think my Browser (Chrome/FireFox - Ubuntu) is not allowing to store an cookie inside an iFrame.

Does someone knows an solution for this Problem? Here are some Parts of the Sourcecode:

$facebook = new Facebook(array(
    'appId'  => 'x',
    'secret' => 'x',
    'cookie' => 'true',
));

$session = $facebook->getSession();
$facebook->setSession($session);


$me = null;
// Session based API call.
if ($session) {
  try {
    $uid = $facebook->getUser();
    $me = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
  }
}

// login or logout url will be needed depending on current user state.
if ($me) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}
A: 

Solved :-)

I have missed to setup the basedomain in configuration.

On the "Conntect" Tab you have to set the Basedomain to your host.

Example: Application is running under http://myapp.com/facebook/html than set the basedomain to myapp.com

Now the cookie is stored correctly.

ArneRie
A: 

i still have huge sessions issues, when ever i run my app directly in the browser, the sessions work properly...but as soon as i start to open them in facebook canvar(iframe app), the sessions simply get lost each time i redirect to another link.I would be really glad if u can help me wid it...thnx

ash