They Gotta Go Sometime!

The final step in this article is to have a way for users to log out. All the code that is required to accomplish that is listed below. We simply include the appropriate common file, unset the authenticated key of the session and direct the request to the login page. Pretty simple!

File: logout.php

<?php
require_once('common.inc.php');
unset($_SESSION['authenticated']);
header('location:login.php');
exit;
?>