I'm new to stackoverflow but I'm not new to PHP. Now I've a funny problem:
I'm developing with XAMPP 7.1.11 with PHP 7.1.11 locally, doing logging out from sessions with
$_SESSION = array();
session_destroy();
in a logout.php file. On top of the page there's a
session_start();
and in past everything went without any problem. Now I did a php version change at the provider from PHP 7.0 to 7.1 and it's not possible to log out any more, the session informations seem not be deleted. I searched the internet but I didn't find a helpful hint and the provider told me to ask some PHP forums.
I tried all hints in the topics
why session_destroy() not working
The session_destroy(); doesn't work correctly on server with php 5.3.21
and many more but nothing is working. A Change from PHP 7.0 to PHP 7.2 at the provider doesn't help as well.
What I'm doing wrong? as I said: locally everything works normally.
Thanks for your help!
Here's the complete logout.php file:
<?php
session_start();
?>
<!-- Import Wordpress -->
<?php
define('WP_USE_THEMES', false);
require('../wp-load.php'); ?>
<?php get_header(); ?>
<link href="cpplattform.css" type="text/css" rel="stylesheet">
<div class="spacer"></div>
<div class="container">
<div class="row">
<div class="<?php if ( is_active_sidebar( 'rightbar' ) ) : ?>col-md-8<?php else : ?>col-md-12<?php endif; ?>">
<div class="content">
<h2 class="entry-title">Logout</h2>
<!----------------------------------------------------->
<section class = "conf">
<i class='fa fa-power-off fa-5x' style ='color:#00ADED'></i>
<br>
<br>
Your logout was successful! Good Bye!
<br>
<br>
<a class="btn btn-md btn-inverse" href="cplogin.php">Login again</a></p>
<?php
$_SESSION = array();
$_SESSION['username'] = "";
session_destroy();
?>
</section>
<!----------------------------------------------------->
</div><!--content-->
</div>
</div>
</div>
<!-- Change all links from Wordpress -->
<script src="cplinkmodify.js"></script>
<?php get_footer(); ?>
I added some static pages and imported a Wordpress theme.