PHP Tutorial : Membership script – Users Logout

Third and final step in our simple membership script. This is the easiest part: logging out users.

Just build a page called logout.php and put a link to it everywhere you want to give users the option to logout & here’s the function:

<?php
function logoutUser() {
session_unset();
session_destroy();
header("Location: homePage.php");
exit();
}
//here's how you put it in action


logoutUser();
?>

They’ll be redirected to the home page, with no active credentials.

Now you know how to build a basic membership script with php including registering, logging and of course logging out.

This script is not advanced, nor it is really secure but is clean, efficient and should give you an head start. Stay tuned for more to come!

One Response to “PHP Tutorial : Membership script – Users Logout”

  1. XkiD | PHP Tutorial : Membership script - Users Logout | blog.xkid.ro Says:

    [...] here:  PHP Tutorial : Membership script – Users Logout Posted in PHP | Tags: dreamweaver, following, function, ideas, one-domain, page-called, [...]


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>