Hey there, I am trying to get my signout button to work. This is what I have in my code:
<!-- Signed In -->
<?php if($_SESSION['*****']['AUTH']) { ?>
<div id="signOut">
Sign Out
</div>
<div id="signIn">
<form name="sendEmail" action="index.php" method="post">
<input type="text" name="name" class="text"/>
<input type="submit" name="subSendEmail" value="Search" class="rounded {transparent} button" />
</form>
</div>
do I need to make a form like the sign in? or what is the best way to do this and terminate the session through php and send user back to index?
thanks!
To log the user out, you need to remove the data from the session. Typically, there’s no problem in clearing out the session when you do this, since any data there is likely to be related to the logged-in session.
You can clear the session data using
session_destroy(). I’d suggest creating a simplelogout.phpscript, similar to the following, which you can then link to:This would redirect the user back to
index.php, returning them to a “non logged-in” view.Alternatively, if you wanted to have the user submit a form to confirm the logout operation, you can simply post the form to the script above, and it would do the same thing: