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";
?>
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’ ) ;
?>
session_start();
session_destroy();
//you can change index.php with any url
header( ‘Location: index.php’ ) ;
?>
Related posts:










January 11th, 2010 at 2:05 am
[...] Go here to see the original: PHP Simple Logout Script [...]http://coderonline.info/php-simple-logout-script/
January 12th, 2010 at 7:33 pm
So well and good posting. i liked it. keep going.
http://www.webroyalty.com
January 13th, 2010 at 6:17 am
Great blog. I bookmarked your site. Th etip on php logout was also good enough.
January 15th, 2010 at 4:23 pm
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
January 15th, 2010 at 7:53 pm
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.
January 17th, 2010 at 2:33 am
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.
January 22nd, 2010 at 4:59 pm
Hmmm. the simple logout script seems very useful and you blog is cracking me out. It has lot of info for me.
February 9th, 2010 at 11:36 am
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.
February 9th, 2010 at 11:49 am
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..
February 21st, 2010 at 12:02 am
@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)
$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;
March 6th, 2010 at 3:08 am
Yes ! I did simple