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 11 of 11
  1. #1
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Logout Is Screwed

    uh oh, another problem.

    my logout page is for some reason not working..

    i created a quick like 7 lines of code when i created to end ALL sessions, yet when i log out from an admin account, i can still delete posts, any ideas?
    PHP Code:
    foreach($_SESSION as $name=>$value){
     
    $_SESSION[$name]=NULL;
    }
    $_SESSION = array();
    if (isset(
    $_COOKIE[session_name()])) {
        
    setcookie(session_name(), ''time()-42000'/');
    }
    session_destroy();
    header("Location: index.php"); 
    Last edited by Jesuspwnt; 12-24-2007 at 01:54 PM.

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    It is likely that your delete code is not properly checking for the existence of the session variable or that the session code on the delete page is recreating the variable.

    You would need to post the code for the delete page to get help with what it is doing.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    that is my session destroying code

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    I think I read somewhere that setcookie doesn't work when used before header(). Could that be the reason, or try what I used in the other thread to avoid that.

    PHP Code:
    unset($_COOKIE,$_SESSION); 

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    So, does the code you posted have a session_start() in it? Otherwise, you are not really operating on an existing session (and you would be receiving a Warning level message from php.)
    Last edited by CFMaBiSmAd; 12-24-2007 at 02:15 PM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #6
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by CFMaBiSmAd View Post
    So, does the code you posted have a session_start() in it? Otherwise, you are not really operating on an existing session (and you would be receiving a Warning level message from php.)
    the only thing you can't see in the code i supplied is that at the top is a require_once to the site's main core. which includes session_start();

  • #7
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    Either the session is not starting due to a headers problem in the logout code or your delete logic is not checking what it should be.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #8
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    there isn't a header problem or it'd echo out an error for sure.
    also it is working, kinda, because it shows the login form again... but i can stll delete shouts

  • #9
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    If you want help with your delete code, you would need to post it, as has already been suggested.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #10
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    wtf? i have!
    check the first post..

    or here it is again just for you
    PHP Code:
    foreach($_SESSION as $name=>$value){
     
    $_SESSION[$name]=NULL;
    }
    $_SESSION = array();
    if (isset(
    $_COOKIE[session_name()])) {
        
    setcookie(session_name(), ''time()-42000'/');
    }
    session_destroy();
    header("Location: index.php"); 

  • #11
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    That is your logout code, not your delete post code.

    You stated your code shows the login form again... but I can still delete shouts. Don't you suppose that the problem is in the delete code you keep mentioning?
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

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