I coded a facebook app in PHP with php-facebook sdk, that is working absolutely fine on my windows 7, wamp.
But, now i implemented it on the webspace running on linux, and i’m getting a session_start() cookie error.
Warning: session_start() [function.session-start]: Cannot send session cookie -
headers already sent by (output started at /mydirectory/index.php:5) in
/mydirectory/src/facebook.php on line 37
I’m not getting why I’m encountering this error.
Below is my code
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
require_once('src/facebook.php');
$app_id = "MY_APP_ID";
$app_secret = "MY_APP_SECRET";
$config = array(
'appId' => $app_id,
'secret' => $app_secret,
'fileUpload' => true,
'cookie' => true
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
// other content
?>
You cannot print HTML before sending headers, the proper way to do it will be
Example: