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 8532975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:50:39+00:00 2026-06-11T09:50:39+00:00

I use Following php code in my wordpress site <?php session_start(); require ‘src/facebook.php’; include

  • 0

I use Following php code in my wordpress site

<?php
session_start();

require 'src/facebook.php';
include 'config.php'; 
$facebook = new Facebook(array(
  'appId'  => $app_id,
  'secret' => $app_secret
));

// Get User ID
$user = $facebook->getUser();

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

if ($user) {
echo "loggedin";

}

else
{
echo "not loggedin";
}

?>

But even when i authenticate my app, I keep on getting not loggedin status.
The above code works fine on normal app, But not in my wordpress site, I get session error, header already sent.

Please anyone tell alternative way to solve this problem.

Note: I dont want javascript

  • 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-11T09:50:41+00:00Added an answer on June 11, 2026 at 9:50 am

    That error is actually probably sent when you do session_start, because there was already some non-header elements built and thus the header of the page is already sent. Meaning, you need to do this before any text is shown in previous scripts (e.g. if you’re including this in the middle of somewhere, just do this in a script which is called before).

    Since you said this is wordpress and you’re just putting this somewhere, you might want to separate the first part into another part of the project (before the headers are sent) and then use the echoes in this place.

    It could also be (I noted you’re using closing ?>), if you’re writing just PHP you might want to avoid using ?> at the end of the files because any blank lines after that might be sent to the output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use the following PHP code: $id = $_GET['page']; $page = include ($id.'.php');
I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
OK, i was using following code to reverse a date to use in php
I use the following php code to get a random amount of URL's form
The following code is in the index.php file of my site and runs every
I use the following code in functions.php in order to load jQuery and set
I use the following php code to connect to mysql database. $hostname = hostname.com;
I use the following PHP code to generate some JS and echo it in
Hello Sir i want send list of data to php server i use following
I am working on a PHP project. There, I often use following syntax to

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.