As I mentioned before, this script doesn't work on my server. So I'm including the code that would create a reusable logout button.
This entire code is stored in the include file.
<?php
// run this script only if the logout button has been clicked
if (array_key_exists('logout', $_POST)) {
// empty the $_SESSION array
$_SESSION = array();
// invalidate the session cookie
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-86400,'/');
}
// end session and redirect
session_destroy();
header ('Location: http://jessicahough.com/location-of-login-form/);
exit;
}
?>
<form id="logoutForm" name="logoutForm" method="post" action="">
<input name="logout" type="submit" id="logout" value="Log out" />
</form>
Now, when I add this line of code...
<?php include('/location-of-include/file.php'); ?>
...to any page, the logout button will appear and be fully functional.