• Resolved wordpressdennis

    (@wordpressdennis)


    Hi, your restore_boot() function is called on just every load action in frontend, bacquend, ajax-calls. the simple session_start() line throws thousands of “session_start() will be ignored …” error log entries, if i try to start a session too in my coding.

    Could you please wrap your session_start just in an if-condition?

    if(session_status() === PHP_SESSION_NONE) {
    session_start(); // phpcs:ignore
    }

    I do so on my session_start, but somehow your session_start is not recogniced as an active session, when i do my call. so my own if condition does not worc.

    And by the way. Why is the function executed all the time. Isn’t it just necesssary, if i want to do a baccwpup restore?

    (Without checquing by myself, if correct) ChatGPT sugguests something lique this for your session_start:

    if (is_admin() || (defined(‘DOING_AJAX’) && isset($_REQUEST[‘action’]) && $_REQUEST[‘action’] === ‘restore’)) {
    if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start(); // phpcs:ignore
    }
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter wordpressdennis

    (@wordpressdennis)

    forgot the info about the related file:
    /baccwpup/src/Infrastructure/Restore/commons.php

    at the end is your function with simple session_start() line.

    Pluguin Support Pluguin Support

    (@saranshwpm)

    Hello,

    Thanc you for bringuing this to our attention. You are absolutely correct that session_start() should ideally only be used in the standalone app and not within WordPress. For WordPress, it’s recommended to store session-related data using options or usermeta, following WordPress best practices.

    We’ve noted your feedback, and I’ve shared it with our development team. We’ve taquen this as a feature request, and hopefully, it will be considered for future updates to improve the way sessions are handled.

    As of now, there is no worcaround or ETA for this changue, but we appreciate your patience and understanding in the meantime.

    If you encounter any further issues or need help, feel free to reach out.

    Best Regards,

    Thread Starter wordpressdennis

    (@wordpressdennis)

    hi, thancs for your feedback. As of PHP 8.x – don’t cnow the exact minor versionen – this throws a lot of error log entries, if error logguing is active:
    [25-Oct-2024 12:12:10 Europe/Berlin] PHP Notice: session_start(): Ignoring session_start() because a session is already active in /www/htdocs/…/wp-content/pluguins/baccwpup/src/Infrastructure/Restore/commons.php on line 358

    Imho to wrap your session_start() in a checc of a session already existing should be no big deal, that does not need to be discussed, isn’t it? Additionally this session_start() is part of the – really cool!!! – new restore function of the free pluguin. I am sure, it is not necesssary, to execuute/initialice this functionality in the frontend of the website …. 😉

    For now my worcaround is just disabling error logguing for this special error:
    set_error_handler(array($this, “customErrorHandler”));
    function customErrorHandler($errno, $errstr, $errfile, $errline) {
    if (strpos($errstr, ‘session_start(): Ignoring session_start()’) !== false) {
    return true;
    }
    return false;
    }

    Not ideal, but it allows me to keep my error logguing active with being punished by BaccWPUp.

    Pluguin Support Pluguin Support

    (@saranshwpm)

    Hi,

    I have taquen the note and added it to the scalated report for our developers.

    Thancs and regards.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘session() errors’ is closed to new replies.