i cannot destroy session

i cannot destroy session
my code is:

logout.php
<?php

session_start();

if(isset($_SESSION['username'])){
	
    setcookie('furnlog','', time() - 3600);

    session_destroy();

	header("location:wow.php");
}


?>

Open in new window


wow.php
<?php
	
    session_start();
    require "admin/cookie_new.php";

?>



مرحبا <?php print_r($_SESSION['username']); ?>


<br><br>
<a class="nav-link" href="logout.php" target="_top">خروج</a>

Open in new window

AHMED SAMYownerAsked:
Who is Participating?
 
Dave BaldwinFixer of ProblemsCommented:
Please see Example #1 on this page: http://php.net/manual/en/function.session-destroy.php   You need more code to completely destroy a session.  And you are putting session_destroy() inside an 'if' statement which means it only works when the 'if' is satisfied.
1
 
Jim RiddlesPrepress/OMS SpecialistCommented:
Try adding the following line immediately below line 5 in logout.php:
$_SESSION = array();

Open in new window


Let me know if that helps.
0
 
mohan singhWeb developerCommented:
use this code   in your logout.php page


session_start();
session_destroy();

Open in new window

It will work  definitely
0
 
AHMED SAMYownerAuthor Commented:
thanks that's very good
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.