Safety logout script

Discussion in 'PHP' started by hhheng, Jul 30, 2007.

  1. #1
    What we need to do before logging out? Can anybody give me the simple but useful logging out script?

    I managed a list of links, and only I can disable and enable the status of the links, and change the link properties in admin page. Currently I'm using 7200 seconds to automatically exit this page, and now I want to exit at any time by just click log out.

    As safe logging out, what we shall do before logging out? Can anybody tell me how to do that?
     
    hhheng, Jul 30, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    That depends on your current script. Usually deleting all session related cookies should work. Additionally you should do something like:
    
    session_unset();
    session_destroy();
    
    setcookie(ini_get('session.name'), null, time() - 3600 * 24);
    
    $_SESSION = array(); // Usually unnecessary.
    
    PHP:
    If your session system is database driven, then you may as well should update a few rows. But I can't tell exactly without seeing your code.
     
    nico_swd, Jul 30, 2007 IP
  3. hhheng

    hhheng Banned

    Messages:
    2,633
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I add the following in the logout.php, and it will exit the logged in page. But if i type in the url for the logged in page again, it will directly go to the page without logging in.

     
    hhheng, Nov 8, 2007 IP