PHP Simple Logout Script

This is quietly simply logout script for your member that already login, by using php session_destroy function if you start login processed with session_start. Of course you can adding more function after session_destroy.

Here are the basic simply code, write and save as php file (ie; logout.php):

Want adding some message or redirect you can adding after session_destroy.
Message After Logout:

<?php
session_start();
session_destroy();
echo "put whatever your message here, you can using html code here";
?>

Redirect After Logout:

<?php
session_start();
session_destroy();
//you can change index.php with any url
header( ‘Location: index.php’ ) ;
?>

Related posts:

  1. PHP Include Function Error, How To Fixed That?
  2. Server To Server File Transfer With PHP Script
  3. How To Insert HTML, Javascript, PHP Code Into Joomla 1.5 Administrator Page
  4. Problem Solving: Images Not Showing In Virtuemart
  5. How To Manage Virtuemart Admin From Joomla Frontend

This entry was posted on Monday, January 11th, 2010 at 12:53 am and is filed under Web and Applications. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

11 Responses to “PHP Simple Logout Script”

  1. PHP Simple Logout Script | Coder Online Says:

    [...] Go here to see the original: PHP Simple Logout Script [...]http://coderonline.info/php-simple-logout-script/

  2. Nick Matyas Says:

    So well and good posting. i liked it. keep going. :)

    http://www.webroyalty.com

    ReplyReply
  3. Apple App Tips Says:

    Great blog. I bookmarked your site. Th etip on php logout was also good enough.

    ReplyReply
  4. NFL Shop Says:

    Great blog. I bookmarked your site.PHP is now popular.Do you have any more about PHP?
    Here I can show some to you: http://www.topnflnews.com

    ReplyReply
  5. ZY21Elisabetta Says:

    I opine that it is workable to see this web page, because here only scholars should notice the superb outcome associated with this post. Therefore, the dissertation writing service could use it for thesis titles accomplishing.

    ReplyReply
  6. Local Services Expert - Janneth Says:

    Got this code running! Thanks for your help. You have a lot of things useful here. I’m sure a lot of people will appreciate the help you’ve been doing so far. Kudos to you and more power to your blog.

    ReplyReply
  7. Ice hockey skates Says:

    Hmmm. the simple logout script seems very useful and you blog is cracking me out. It has lot of info for me.

    ReplyReply
  8. ads Company Says:

    Right now the simple script will logout all users if no acitivty is detected for a certain amount of time. I want this to work with the exception of a certain user.

    ReplyReply
  9. ads Company Says:

    This means that the next person to use the PC can access the website without a login because the last user is still logged in..

    ReplyReply
  10. El Nino Says:

    @ads Company:

    I think it should put on member / restricted page to limiting login time. You can using time function for that purpose, ie; (put this after session start)

    //define the current time
    $current = time();
    //then we decided how long the limit, 60s X 30
    $limit = $current – 60 * 30;

    //this is for check how long last user activity
    if (isset ($_SESSION['last_activity']) &&
    $_SESSION['last_activity'] < $limit) {

    //now the rule of limit time will work and redirect if time limit expired
    $_SESSION = array();
    header('Location: http://yoursite/logout.php‘);
    exit;
    } else {

    //But if time not yet expired, then user will still logged in
    $_SESSION['last_activity'] = $current;

    ReplyReply
  11. Andrei A. Says:

    Yes ! I did simple

    ReplyReply
 

Leave a Reply