• Resolved StevenP94

    (@stevenp94)


    Hi, digging in my logs while looking for performance optimization, I found a lot of this:
    PHP Warning: session_start(): Failed to read session data: user (path: /var/lib/php/sessions)

    After a lot of searches I found that this message could be caused from a read operation that returns null instead of empty string, so I made a workaround:

    I’ve changed line 74 of wp-native-php-sessions/inc/class-session-handler.php from

    return $session->get_data();

    to

    return $session->get_data() ?: '';

    Is this correct? There is a better way to solve this problem?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor jazzs3quence

    (@jazzs3quence)

    That looks valid to me. Are you able to confirm whether that solved the seesion_start error log messages?

    Thread Starter StevenP94

    (@stevenp94)

    Yes, it seems so

    Plugin Contributor jazzs3quence

    (@jazzs3quence)

    Thanks for confirming. Proposed fix looks good to me, I will work on getting this added to the plugin. Thanks for the report!

    Plugin Contributor jazzs3quence

    (@jazzs3quence)

    @stevenp94

    Circling back to this, I am unable to reproduce the issue. Can you tell me about your environment? What version of PHP are you running? Is this a local environment (if so, what are you using for local dev?) or is this happening on a remote host?

    Thread Starter StevenP94

    (@stevenp94)

    My environment:
    Apache/2.4.41 (Ubuntu)
    PHP 7.4.3
    WordPress 6.1.1

    This happens on remote host, probably when someone try to get access and is not authorized (security drop the connection).

    $session->get_data() returns null but $session is not null.
    I think that my solution can be a ‘safety’ change that increase the code solidity, just don’t know if there is something better, I’m not so experienced in PHP

    Thanks for your time

    Plugin Contributor jazzs3quence

    (@jazzs3quence)

    Cool cool. This helps. I agree it’s probably a good thing to fail gracefully, I just wanted to make sure I understood the context.

    Plugin Contributor jazzs3quence

    (@jazzs3quence)

    This will go out in the next update. Thanks for the report!

    Thread Starter StevenP94

    (@stevenp94)

    You’re welcome!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘PHP Warning: session_start(): Failed to read session data: user’ is closed to new replies.