会话没有被破坏[重复]

This question already has an answer here:

i am just trying to destroy my session with session_destroy but its not getting destroy this is my code of logout.php

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

i am getting a waring

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

if i remove third line from comment and click again on logout its showing me array of $_SESSION with all data and if i do comment it again without refreshing browser and then refresh the browser then session is getting destroy i am calling this page from my index page and on index page i have written session_start

</div>

Declare session_start(); first to close the existing sessions.

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

You forgot the session_start before destroy it. and you redirect using php, here you are using script to redirect

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

?>