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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.