Symbianize





Programming Discussions related to C++, HTML, PHP, ASP, ColdFusion, JavaScript, Perl, Phyton, Ruby, WML, SQL, XML, and other programming languages.

Reply
  #1  
Old 6th Jul 2011 Wed, 18:18
nodiad Male nodiad is offline
Amateur
 
Join Date: Apr 2008
Posts: 56
Reputation: nodiad is an unknown quantity at this point
Default PHP idle time auto logout

guys, any idea kung pano gawin sa php ung mag aauto log out ung isang page given a time amount of idle time ??? thanks


Reply With Quote
Other Resources
  #2  
Old 6th Jul 2011 Wed, 21:56
mipfer's Avatar
mipfer Male mipfer is offline
Forum Consultant
 
Join Date: Feb 2009
Posts: 1,117
Reputation: mipfer will become famous soon enoughmipfer will become famous soon enough
Default Re: PHP idle time auto logout

eto sir:

every page dapat may ganito:
echo '<meta http-equiv="refresh" content="3; logout.php" />';

replace mo nalang yung mga red highlighted text sa preference mo.. yung 3 is seconds yun.. so dun mo papalitan kung ilan seconds silang idle bago malogout..

or you can make a countdown like function using mktime function of PHP, though same effect lang din yan, mas simple lang yung meta refresh..


or kung gumagamit ka ng sessions, pwede siguro yung session destroy function, if else ka nalang sa time mo..

gaya nito:

Quote:
<?php
session_start();
$_SESSION['session_time'] = time(); //got the login time for user in second
$session_logout = 900; //it means 15 minutes.
//and then cek the time session
if($session_logout >= $_SESSION('session_time']){
//user session time is up
//destroy the session
session_destroy();
//redirect to login page
header("Location:the-path-your-login-page.php");
}
?>
source:
*Only fully-registered users can see this link.*



Join kayo sa Xmas Raffle ng Acer. Lupet ng mga premyo nila!!!
Follow the steps here: http://www.symbianize.com/showthread.php?t=891040
Reply With Quote
  #3  
Old 7th Jul 2011 Thu, 13:10
nodiad Male nodiad is offline
Amateur
 
Join Date: Apr 2008
Posts: 56
Reputation: nodiad is an unknown quantity at this point
Default Re: PHP idle time auto logout

code working sir!!!!


Reply With Quote
Reply

Thread Tools

Forum Jump


All times are GMT +8. The time now is 06:48.