Results 1 to 6 of 6

Thread: Logout Button

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Logout Button

    I have a logout button with that links to the following page which contains:

    PHP Code:
    <?php 
    //log out// 
    unset($_SESSION['blnUserLoggedIn']); 
    //session_destroy(); 
    header('Location: welcome.htm'); 
    ?>
    But when you get re-directed back to the welcome page, the user is still logged in... Any ideas?

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Have you called session_start() before session_destroy()?
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yea I call it on a page called top.php, then this has a logout button which links to logout.php which has the above... When the user clicks it redirects to another page called bottom.php... If I change the re-direct page to top.php, it's still logged in... When I remove the comments around session_destroy() I get the following:

    Code:
    Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/logout.php on line 5
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/html/logout.php:5) in /homel/logout.php on line 6

  4. #4
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Try calling:
    PHP Code:
    session_start();
    session_destroy(); 
    on a separate file and see if it logs you out.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  5. #5
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It just says now:

    Code:
    Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/html/logout.php on line 5
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/html/logout.php:5) in /home/html/logout.php on line 6

  6. #6
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Did you have any HTML code in that file? Just put <?php session_start(); session_destroy(); ?> and nothing else in that file.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

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