1

The first time I visit, I get a blank page - no text whotsoever if i click "view source", but a session cookie is added. The second, everything runs as it should. If I delete the cookie, I get a blank page again. Same in all browsers - Firefox 4, IE 9, Chrome 11. PHP 4.4.9

<?php
session_start();
echo "hello";
?>

Update:

Session Support     enabled
Registered save handlers    files user 

session.auto_start  Off Off
session.bug_compat_42   On  On
session.bug_compat_warn On  On
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  100 100
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   /tmp    /tmp
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    Off Off
session.use_trans_sid   On  On

This is my phpinfo on sessions I've already tried ini_set("display_errors", 1); I've also tried setting ini_set('error_log') to a file in a folder that is writable, but I don't get any errors (even if I write "asdfasdf(asdf(0)}" as the first line.)

Charles
  • 50,943
  • 13
  • 104
  • 142
sabof
  • 8,062
  • 4
  • 28
  • 52
  • Is there no possibility for you to update to a newer PHP version? – Felix Kling May 02 '11 at 23:13
  • 1
    turn on error checking, there will be errors you just are not seeing them. –  May 02 '11 at 23:17
  • It's not my server, so I can't update. In any case I doubt that a version of PHP would be released, that would give such an obvious error. I've tried adding, "error_reporting(E_ALL);" before session_start(), but I still get just a blank page – sabof May 02 '11 at 23:23
  • add: error_reporting(E_ALL); ini_set("display_errors", 1); –  May 02 '11 at 23:30
  • 1
    What information does phpinfo() show regarding sessions? Anything obviously wrong? – David May 02 '11 at 23:31
  • made an update on the question – sabof May 02 '11 at 23:44

2 Answers2

1

as a workaround, check for the session before you start it and refresh/redirect the page imediately after you start it

CSᵠ
  • 10,049
  • 9
  • 41
  • 64
1

Sounds like an issue with your php.ini

I would check the "session.save_path" and "session.use_cookies" entries and the directories referenced (permissions etc). Also use phpinfo() to spot configuration errors.

David
  • 224
  • 3
  • 16
  • Can you try changing session.use_only_cookies to On. Also is /tmp a valid path on the server with all relevant privileges and enough free space? Can you clear all the existing sessions? – David May 02 '11 at 23:49
  • Also have you had a look in your error log to see if anything is being written when you access the page? – David May 02 '11 at 23:56
  • I've added ini_set('session.use_only_cookies', 'On'); as the first line, it works now. Still, I am curious what was the problem? + Don't know how to access the error log phpinfo says error_log no value, if that's of any help – sabof May 03 '11 at 00:07
  • It will be hard to tell without being able to view the actual errors being generated, but forcing cookies isn't a bad thing as it prevents attacks involving session IDs in the URL. I presume you are using Apache? If so you could try looking in /var/log/httpd/error_log – David May 03 '11 at 00:18
  • Yes, it's apache. It's a public server, I doubt that I have the necessary privileges. I'll google to find if there is a way I can get an error log. Thanks – sabof May 03 '11 at 00:23