Let's see....
Logic goes as follows:
1) Start the session
2) If your session variables are not set, you will prompt the user to log-in, for this page can not be reached by manually typing the URL in the browser
3) If your session variables ARE indeed set, unset them, and then destroy the session.
<?php
// Start the session
session_start();
// Check to see if the variables are set
// If they are not, re-direct them to a login page
if (!isset($_SESSION['SESSION_UNAMEMAIN']))
{
header ("Location:"login.php");
}
// Otherwise, unset the variables, destroy the session, and then define your headers
else
{
//Unset your variable
unset($_SESSION['SESSION_UNAMEMAIN']);
//Destroy the session
session_destroy();
// Define your headers
header("Cache-Control: no-cache, must re-validate");
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
}
?>
It is always good to think of sessions in this way...If a session isn't set, do this....If a session is set, do that...
Give this a shot, and let me know how you're doing...Also, a tutorial you might want to read up on if you're having trouble...
www.phpfreaks.com/tutorials/41/0.php
Mike