Facebook PHP SDK and Wordpress Error

Posted by Gecko on Pro Webmasters See other posts from Pro Webmasters or by Gecko
Published on 2012-05-30T22:10:46Z Indexed on 2012/05/30 22:51 UTC
Read the original article Hit count: 499

I have a developer environment setup with WAMP, Wordpress, and PHPEdit IDE. I use the Facebook, Twitter, and YouTube API's in a sidebar. I'm using Facebook's PHP SDK to display information(no login or admin functions). Since the FB SDK and WP use session_start() I get the following warning:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\dfi\wp-content\themes\DFI\header.php:12) in C:\wamp\www\dfi\wp-content\themes\DFI\api\facebook.php on line 36

I'm trying to figure this out by using the warning output but it doesn't help considering the following. I know about clearing white space and characters before and after <?php ?> and placing session_start() before any http output. I use unix line enders and UTF8 encoding without BOM. My host server is not set up for output_buffering.

header.php line 11 to 13

11 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
12 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes();?>>
13 <head>

It looks like the warning comes from inline php code. I don't know what I can do to fix this line.

facebook.php line 34 to 37

34    public function __construct($config) {
35    if (!session_id()) {
36      session_start();
37    }

I don't think I can stop either FB or WP from calling session_start() without breaking everything. How do I make Wordpress and Facebook play nicely together without this error?

© Pro Webmasters or respective owner

Related posts about Wordpress

Related posts about facebook