Tag Archives: session

use session create member log in wih mysql–continue

then you should create your logout.php

here is the code:

<?php
  session_start();
 
  // store to test if they *were* logged in
  $old_user = $_SESSION[‘valid_user’];  
  unset($_SESSION[‘valid_user’]);
  session_destroy();
?>
<html>
<body>
<h1>Log out</h1>
<?php
  if (!empty($old_user))
  {
    echo ‘Logged out.<br />’;
  }
  else
  {
    // if they weren’t logged in but came to this page somehow
    echo ‘You were not logged in, and so have not been logged out.<br />’;
  }
?>
<a href=”authmain.php”>Back to main page</a>
</body>
</html>

Advertisements

Unsetting Variables and Destroying the Session

When you are finished with a session variable, you can unset it.You can do this directly
by unsetting the appropriate element of the $_SESSION array, as in this example:
unset($_SESSION[‘myvar’]);
Note that the use of session_unregister() and session_unset() is no longer
required and is not recommended.These functions were used prior to the introduction
of $_SESSION.
You should not try to unset the whole $_SESSION array because doing so will effectively
disable sessions.To unset all the session variables at once, use
$_SESSION = array();
When you are finished with a session, you should first unset all the variables and
then call  session_destroy();
to clean up the session ID.