• Wp and the hoster swear at the php session. It is clear that wp does not use sessions.

    Wp error: The PHP session was created by calling the session_start () function. This prevents REST API and loopback requests from working. The session must be closed with the session_write_close () function before making any HTTP requests

    I use are child theme. If i add this cod in function.php my child theme:

    add_action('init', 'start_session', 1);
    
    function start_session() {
    if(!session_id()) {
    session_start();
    }
    
    add_action(‘wp_logout’, ‘end_session’);
    add_action(‘wp_login’, ‘end_session’);
    add_action(‘end_session_action’, ‘end_session’);
    
    function end_session() {
    session_destroy ();
    }

    This action don’t work. I think becase need to add a global variable yes?

    This is.
    $foo = ‘Foo Data’;
    $_SESSION[‘foo’] = $foo;

    But i dont now when file i need rhis global variable.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I can’t tell if you are asking how to do PHP sessions for something you are writing, or if you are trying to fix an unclosed session that some plugin left.

    If you are writing code using PHP sessions, you really should research it to know what to do. Otherwise, steer clear of it.

    If you are trying to fix a problem from a plugin, you should identify which plugin it is and ask at the plugin’s support forum, so all the users get the fix.
    You can use the Health Check plugin in Troubleshoot mode to disable plugins/theme for your user only, to isolate what code has the session.

    Thread Starter llfoto2545

    (@llfoto2545)

    the plugin is causing the problem. The site has Elementor, Woocommerce, crocoblock pack installed. Here is the crocoblock package, one of its plugins creates it. thanks. for help. I’ll test it today.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP session’ is closed to new replies.