PHP session handling errors

后端 未结 13 1169
感动是毒
感动是毒 2020-12-15 17:33

I have this at the very top of my send.php file:

ob_start();
@session_start();

//some display stuff

$_SESSION[\'id\'] = $id; //$id has a value         


        
13条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 18:03

    When using the header function, php does not trigger a close on the current session. You must use session_write_close to close the session and remove the file lock from the session file.

    ob_start();
    @session_start();
    
    //some display stuff
    
    $_SESSION['id'] = $id; //$id has a value
    session_write_close();
    header('location: test.php');
    

提交回复
热议问题