If you want to completely destroy the session, you need to do more, just
session_destroy();
First, you must disable any session variables. Then you must destroy the session, and then close the session record. This can be done as follows:
<?php session_start(); unset($_SESSION); session_destroy(); session_write_close(); header('Location: /'); die; ?>
The reason you want to have a separate script to exit is because you don't accidentally execute it on the page. So make a link to your script output, then the header will be redirected to the root of your site.
Edit:
You need to remove () from the exit code at the top of your script. it should just be
exit;
Mic1780
source share