PHP session destroyed / lost after header

前端 未结 6 2045
无人共我
无人共我 2020-12-10 02:39

I\'ve got a script that sets some session values before redirecting to / using header().

I\'ve read many posts about the $_SESSION

6条回答
  •  天涯浪人
    2020-12-10 03:31

    header must be sent before session close

    session_regenerate_id(true);
    
    header("Location: /");
    // the header must be sent before session close
    session_write_close(); // here you could also use exit();
    

提交回复
热议问题