会话没有破坏

时间:2018-08-18 17:16:03

标签: php session session-variables

我只是想破坏与session_destroy的会话,但没有破坏这是我logout.php的代码

<?php
session_destroy();
//print_r($_SESSION);exit;  
?>
<script type="text/javascript">
    location.href=root_path+"index/";
</script>

我正在警惕

Warning: session_destroy(): Session object destruction failed in F:\xampp\htdocs\synthesis\module\login\logout.php on line 3

如果我从注释中删除第三行,然后再次单击注销,它显示了包含所有数据的$ _SESSION数组,如果我在不刷新浏览器的情况下再次对其进行注释,然后刷新浏览器,则会话将被破坏 我从索引页面调用此页面,并且在索引页面上我已编写session_start

2 个答案:

答案 0 :(得分:0)

声明session_start();首先关闭现有的会话。

    <?php
     session_start(); 
     session_destroy();
     //print_r($_SESSION);exit;  
    ?>
    <script type="text/javascript">
       location.href=root_path+"index/";
    </script>

答案 1 :(得分:0)

您在销毁session_start之前忘记了它。并且您使用php进行重定向,这里您使用脚本进行重定向

<?php 
session_start();
session_destroy();  
header("Location: index.php");

?>