Search code examples
phpfacebookinternal-server-error

Interal Server Error 500 - session_start()


Well, I found quite a lot of threads with ISE 500, but none of the solutions worked for me.

I developed a facebook app for our client to present some audiotracks and, of course, would like to pass some parameters to the application per app_data param. So I integrated the facebook sdk 3.1.1. did everything to connect properly to facebook.

On my local xampp everythings works fine, our companys webserver also runs the application without any problems, so does my private webspace. But when I upload the application to the clients server I get a 500: Internal Server Error. To rule out any weird scripting errors on my side I tried to execute the example.php that comes with the sdk. Same error. Even when I just tried to instantiate the Facebook class like this:

<?php

require '../src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => '???',
  'secret' => '??????',
));
?>

I already looked at the servers error logs. The only thing it mentions is this:

"Premature end of script headers: example.php"

I also used the widely suggested error_reporting(E_ALL); to avoid wrong errorhandling on the serverside. Nothing. The server just wont tell me whats wrong.

I found quite a lot of reasons why other people got this error, the most prominent ones:

  • Missing ?> tag in the facebook.php / base_facebook.php
  • Multiple instances of the Facebook- and FacebookApiException

...none of the provided solutions worked for me.

So I tried to compare the phpinfos of both, the client and our companys server. Of course there were some differences, but nothing obvious to me. I looked for the basic things people at the forums had already associated with a ISE 500 like the cURL extension, php version (5.3.9). I am not a server-admin, I only got a very basic knowledge of server configurations. So to be sure that something is missing i tried to find server requirements for the facebook sdk...

...but the whole web won't tell me server requirements for the facebook sdk. Even the facebook documentation doesn't mention anything. So i hope there might be someone around here who can help me with this.

And yes... i already asked the server-admin for help, he just looked at me with two questionmarks in his eyes... and yes... i have to use the clients server :( sigh

Thanking you in anticipation...


UPDATE:
I will list the things i tried in response to your suggestions:

Server:
- cURL extension is installed (7.20.1)
- php version is 5.3.9.
- tried to include other files, works fine. Doesnt seem to be a path-problem
- Server error logs just show "Premature end of script headers: example.php"
- log_errors is enabled. error_log says 'no value'
- tried ini_set("display_errors", true); for bug tracking... no effect


UPDATE 2

So I was able to identify the problem after checking the facebook files row by row. The Internal Server Error 500 is thrown right at the start after trying to start a session:

if(!session_id())
{
    session_start();
}

I forwarded this info to the server-admin and the client... i guess its out of my hands now, i will update this post when i get an answer. Thanks for your feedback guys :)


SOLUTION

Ok the server-admin now identified the problem. The session.save_handler was set to 'user', He changed it to 'files', now everything works.:

session.save_handler = files

Thanks again for help!


Solution

  • The phpinfo() had the answer. Under session, the save_handler parameter had to be set from:

    session.save_handler = user

    to:

    session.save_handler = files