Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: logout script

  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts

    logout script

    For some reason I am able to run my login script which after doing so will put more options into my menu to allow me to do other things. Well one option it brings up of course is "logout". Well for some reason it doesnt logout. I dont know if you will need more info but this is my log out script, I cant seem to see where the issue is.
    PHP Code:
    <?php
    //this is the log-out page for the site

    //include the configuration file for error management and such
    require_once ('config.inc');

    //set the page title and include the header
    $page_title 'Logout';
    include (
    'header.php');

    if (isset(
    $_SESSION['first_name'])) { //if no first name variable exists, redirect the user

    header ("Location: http://" $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
    ob_end_clean(); //delete the buffer
    exit();//quit the script

    } else { //log the user out
        
    $_SESSION = array(); //destroy the variables
        
    session_destroy(); //destroy the session itself
        
    setcookie (session_name(), ''time()-300'/'''0); //destroy the cookie
        
    }

    //print a customized message
    echo "<h3>You are now logged out.</h3>";

    include (
    'footer.php');
    ?>
    Thanks for the help

  • #2
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts
    if (isset($_SESSION['first_name'])) means that if it DOES exist. I think you need

    if(!isset($_SESSION['first_name']))

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    108
    Thanks
    0
    Thanked 2 Times in 2 Posts
    oops typo thanks for pointing out my blindness and the ability to type a script...lol


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •