session is not destroyed

前端 未结 5 649
醉梦人生
醉梦人生 2021-01-27 06:55

i have this file

secure.php

session_start();
if(empty($_SESSION[\'u_name\'])) {
    header(\"Location:emprego.php\");
}

if(isset($_GET[\'logout\'])) {
         


        
5条回答
  •  独厮守ぢ
    2021-01-27 07:32

    All the other solutions didn't seem to work for me. However, this workaround did the trick. Basically, the code below keeps calling the logout until the logout finally succeeds:

    if (isset($_GET["logout"])){
        if (isset($_SESSION["username"])) {
            unset($_SESSION["username"]);
            session_destroy();
            header("Location:/?logout=true");
            exit;
        }
        header("Location:/");
        exit;
    }
    

提交回复
热议问题