Troubles with a PHP session variable after form submission

前端 未结 3 672
Happy的楠姐
Happy的楠姐 2021-01-22 12:36

I\'m setting a PHP session variable with a success message for a HTML form that I\'m submitting. If there are no form errors, I redirect to the same page (using header()) and di

3条回答
  •  伪装坚强ぢ
    2021-01-22 13:31

    Destroy the session:

    Change your code to look something like this

    if(isset($_SESSION['sentData'])
    {
    echo "Your message";
    
    //This
    session_destroy();
    //or this
    unset($_SESSION['sentData']);
    }
    

    EDIT:

    Actually no, put this at the end of form.php/your template file/after you have displayed the message:

    unset($_SESSION['status']);
    

提交回复
热议问题