Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:50:08+00:00 2026-06-04T23:50:08+00:00

I have a developer environment setup with WAMP, WordPress, and PHPEdit IDE. I use

  • 0

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?

EDIT:
To stop the warning from displaying I put @ in front of session_start().

public function __construct($config) {
    if (!session_id()) {
      @session_start();
    }

Its only a workaround and I would still like to find the root of the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:50:10+00:00Added an answer on June 4, 2026 at 11:50 pm

    As discovered in your comments, the issue isn’t about including the PHP file, rather it is where you define the class. Creating the instance of the Facebook class can be safely done (as far as I know, it works for me) in the wp hook. This will allow you to define the instance of the class before any HTML output, then you can use that variable anywhere in your class.

    You do however want to be sure to only include the class once, but you can instantiate the class as many times as you want.

    Here’s a basic example to get you started:

    if( !class_exists( 'Facebook' ) ) {
        require_once 'facebook.php';
    }
    
    if( !class_exists( 'YourClass' ) ) {
    
        class YourClass {
    
            public $facebook = null;
    
            public function __construct() {
    
                add_action( 'wp', array( $this, 'define_facebook' ) );
                add_action( 'any_hook_after_wp', array( $this, 'example_usage' ) );
    
            }
    
            public function define_facebook() {
                global $post;
    
                // Assuming you are using post meta for the app ID and secret, you can use other methods though
                $app_id = get_post_meta( $post->ID, 'appId', true );
                $app_secret = get_post_meta( $post->ID, 'appSecret', true );
    
                $this->facebook = new Facebook( array( 'appId' => $app_id, 'secret' => $app_secret ) );
    
            }
    
            public function example_usage() {
    
                if( !is_null( $this->facebook ) ) {
    
                    // Lets see what we have here..
                    echo "<pre>";
                    print_r( $this->facebook );
                    echo "</pre>";
                    exit;
    
                }
    
            }
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our developer environment setup tends to have a lot of moving parts with a
How do you setup a multi-developer XDebug PHP environment? I have the following setup:
I have a website that per original developer was working on local environment. I
I have Client-Server environment and developed a project for Client-Server. I need to share
In the software development environment where I work we have a group of developers
I have to develop a database for a unique environment. I don't have experience
I have a developer license and I've generated .mobileprovision and .cer files. I've put
The purpose is to have a USB flash to have a developer seat everywhere.
I have been a developer for approx 10 yrs. I want to know how
I have a Flash developer I'm working with. This person is building a tool

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.