PHP Warning: session_start() - not sure why

Discussion in 'PHP' started by grunff, Aug 5, 2007.

  1. #1
    Hi all,

    I'm trying to fix a problem with a site which uses sessions. I keep seeing this error in the error log:

    
    PHP Warning: session_start(): open(/tmp/sess_6d5f9217920bb7a27c7108fec4587a20, O_RDWR) failed: Permission denied (13) in /home/public_html/includes/inc.php on line 1697
    Code (markup):

    inc.php is the main site include, which is included on every page. The session handling bit looks like this:

    
    if ($ss != "")
    {
      session_id($ss);
    }
    
    session_start();
    
    Code (markup):
    The variable $ss is used to pass the session id between the http: and https: sections of the site.

    Any idea as to why I'm getting this warning?

    Sessions are being created fine for both http and https.

    The only other possibly relevant bit of info is that it's set to use_only_cookies.

    Happy to provide more info if necessary.

    TIA
     
    grunff, Aug 5, 2007 IP
  2. Dr Small

    Dr Small Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It's a permissions problem. Check around and look at permissions.
     
    Dr Small, Aug 5, 2007 IP
  3. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok, we recently had a customer run into this problem. Are you making use of PHP4 as well as PHP5 on your site? If so are you making sure to use session_name on for the PHP4 and PHP5 parts? Otherwise what happens in most configurations anyways the PHP4 is an apache module and it creates the nobody user. Then the PHP5 configuration attempts to use the session and it cannot. The same the other way the PHP4 cannot access the PHP5 session either. This is all due to the session file ownership PHP4 uses nobody and PHP5 uses your username.
     
    InFloW, Aug 5, 2007 IP
  4. grunff

    grunff Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    But sessions are working just fine, and the session files are being written and read to the /tmp directory *&most* of the time without any errors.
     
    grunff, Aug 5, 2007 IP
  5. grunff

    grunff Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    No, just PHP4.
     
    grunff, Aug 5, 2007 IP
  6. RichardKnox

    RichardKnox Peon

    Messages:
    209
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    session_start() should be at the top of the page if memory serves.
     
    RichardKnox, Aug 6, 2007 IP