Destroy a PHP session on clicking a link

Make a page called logout.php

Logout.php_____

<?php
Session_start();
Session_destroy();
header('Location: ' . $_SERVER['HTTP_REFERER']);

?>

Your page______

<a href="Logout.php">Logout</a>

Wrong code. you can use this code:

<?php if($_GET['logout']==1) session_destroy(); ?>
<a href="?logout=1">Logout</a>

No it is not a valid code. It will destroy the session at the time of loading the php page.

For destroying session on click you should write

<a href="logout.php" >Logout</a>

in logout.php

session_destroy();