This lesson is part of an ongoing User Authentication tutorial. The first
part is here: User Authentication along with all
the files you need.
You'll also want to ensure that your users can log out successfully. This is quite easy, as the only thing you need to do is to destroy the session. Fortunately, PHP has an inbuilt function for that:
In the next part, we'll take a look at how to register a new member.
You'll also want to ensure that your users can log out successfully. This is quite easy, as the only thing you need to do is to destroy the session. Fortunately, PHP has an inbuilt function for that:
session_destroy();
When this function is executed, all the session variables that you set up for
the user will be destroyed. Open up your page called page2.php, and take
a look at the code. It's just this, though:
<?PHP
session_start();
session_destroy();
session_destroy();
?>
Quite bizarrely, you have to start the session first, even though you've been
using sessions throughout your pages! So that the user can log out, you can
add a link on your page1.php page:
<A HREF = page2.php>Log out</A>
When the user clicks this link, the log out script will be executed. If you
try to reload page1.php, you'll be redirected to the login page.In the next part, we'll take a look at how to register a new member.
0 Response to "PHP Log Out tutorial"
Post a Comment