0

The site is on a shared hosting service by IWeb. The site has stopped answering every time the script does a session_start(). It was working before and the code hasn't changed.

I am pretty sure its a server problem since IWeb is working on some other bug we had and they are that incompetent. But, as usual they ask for all sorts of proofs before they actually investigate.

So I created a a script that contains ONLY this:

ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();

And sure enough if I run it I get the internal server error and nothing in the error_logs.

My question is what could be causing this? Permissions on the session folder? We are on shared hosting, so we can't change anything server side.

Is there anything I can tell the IWeb technician that will convince them to fix the issue?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Iznogood
  • 12,447
  • 3
  • 26
  • 44
  • You need to turn up the error log level. It's sometimes just disabled per default on vhosts. Otherwise hard to guess. (Out of disk space?) – mario Jan 17 '12 at 16:57
  • 1
    `and they are that incompetant` - may be time to look for a new host then? – DaveRandom Jan 17 '12 at 16:58
  • @mario error reporting is at E_ALL. – Iznogood Jan 17 '12 at 17:00
  • @DaveRandom our client chose IWeb. We would NEVER recommend them. – Iznogood Jan 17 '12 at 17:00
  • Does this belong on server fault> – H Bellamy Jan 17 '12 at 17:00
  • @Iznogood make sure you `ini_set('display_errors',1);`... – DaveRandom Jan 17 '12 at 17:00
  • @HBellamy good point (although I would say webmasters.SE) - voting to move – DaveRandom Jan 17 '12 at 17:01
  • @H.Bellany maybe but whatever they suggest I could never try. I am comming from the standpoint of a developer. – Iznogood Jan 17 '12 at 17:01
  • No, not the PHP error_reporting, the Apache ones http://httpd.apache.org/docs/2.1/mod/core.html#errorlog and http://httpd.apache.org/docs/2.1/mod/core.html#loglevel – mario Jan 17 '12 at 17:04
  • possible duplicate of [Apache/PHP: error_log per Virtual Host?](http://stackoverflow.com/questions/176/apache-php-error-log-per-virtual-host) – mario Jan 17 '12 at 17:07
  • Did they recently enable suPHP? I had a similar problem once when this was done incorrectly. With suPHP, you can't use a folder that has too high of permissions for session cache and the default location (/tmp) is usually 777. – AndrewR Jan 17 '12 at 17:22

4 Answers4

2

you could get the session path with the function

$sessionpath = session_save_path();

you could then display the permissions set on the path

echo substr(sprintf('%o', fileperms($sessionpath)), -4);

usually if it's a permissions problem, you would get an error saying something about access denied when session start is called.

dqhendricks
  • 19,030
  • 11
  • 50
  • 83
  • Well I pasted your code in my test script and it displayed 0. That is to say it displayed the number zero not nothing. But no errors. Actually session_save_path returns an empty string. – Iznogood Jan 17 '12 at 18:26
  • weird, default should be "/tmp". must be changed in your php.ini. http://www.php.net/manual/en/session.configuration.php#ini.session.save-path – dqhendricks Jan 17 '12 at 18:30
  • @Iznogood would probably want to set it to a folder outside of tmp and outside of public. you can do this programatically at the start of your script instead of using ini with the session_save_path() function, but ini is preferred. – dqhendricks Jan 17 '12 at 18:32
  • Well I am 100% sure its the web host that is at fault here. – Iznogood Jan 17 '12 at 18:33
0

If you are getting an Internal Server Error when using PHP session_start(), check to see how many files are in the folder configured as the session.save_path. Here's a quick script:

set_time_limit(0);
ini_set("memory_limit","256M");

$directory = session_save_path();
$filecount = count(glob($directory . "/*"));

echo $directory." file count = ".$filecount;

If there are a bunch of files in there (100s of thousands), it can cause occasional Internal Server Errors that can be resolved temporarily by deleting the client cookie. On a shared server, it's a good idea to store session cookies in your own file system area anyway, so the solution I am using is to change the session.save_path for any scripts that start a session or set a session variable.

ini_set('session.save_path', dirname(__FILE__) . '/../session');
0

So in the end it was indeed the host provider. I opened a ticket with them and they fixed it "eventually".

Nothing changed on my side so it was a server issue. I do not have the details of what was fixed but I am pretty sure it had something to do with permissions on the /tmp folder.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Iznogood
  • 12,447
  • 3
  • 26
  • 44
-2

The host provider IWeb is not a good host. This is a server side problem and it's time to find new web hosting.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126