Code for Beginners-session out Timer !
This is code is used as a session timeout timer and acts like set cookie. I use this code to set a five minutes session. You Can change the session timeout (in minutes) in the file named: end_timer.php
file 1 : login.php
==================
<?php
//start the time @ your login page
session_start ();
$start = time ();
$_SESSION [ 'time_start' ]= $start ;
/*get the login info & set to session */
?>
file 2 : home.php
=================
<?php
$end = time ();
include( "start_timer.php" );
include( "end_timer.php" );
/* session variables like user login info .. */
?>
file 3 : start_timer.php
========================
<?php
$start = $_SESSION [ 'time_start' ];
$ItemStartDate = $start . "<br>" ;
$ItemEndDate = $end . "<br>" ;
// $Today = time();
$TimeLeft = $ItemEndDate - $ItemStartDate ;
//$TimeLeft = $ItemEndDate - $ItemStartDate;
if( $TimeLeft > 0 )
{
$ADayInSecs = 24 * 60 * 60 ;
$Days = $TimeLeft / $ADayInSecs ;
$Days = intval ( $Days );
$TimeLeft = $TimeLeft - ( $Days * $ADayInSecs );
$Hours = $TimeLeft / ( 60 * 60 );
$Hours = intval ( $Hours );
$TimeLeft = $TimeLeft - ( $Hours * 60 * 60 );
$Minutes = $TimeLeft / 60 ;
$Minutes = intval ( $Minutes );
$TimeLeft = $TimeLeft - ( $Minutes * 60 );
$Seconds = $TimeLeft ;
$Seconds = intval ( $Seconds );
$TimeLeft = $TimeLeft - ( $Seconds / 60 * 60 );
$MilliSeconds = $TimeLeft ;
}
?>
file 4 : end_timer.php
===================
<?php
$Seconds . " Seconds " ;
$time_out = 5 ;
if( $Minutes < $time_out ){
$_SESSION [ 'time_start' ]= $end ;
}else{
include( "logout.php" );
}
?>
file 5 : logout.php
===================
<?php
//log out /session time out after 5 minutes of idle time
session_destroy ();
?>
Securing Web Forms with Simple PHP-CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart)
Categories : PHP , Security , GD image library , Sessions Basic Authentication with sessions Categories : PHP , Beginner Guides , Authentication , Form Processing , Sessions Simple Session example Categories : PHP , Beginner Guides , Sessions Form Security - Match A Value For Success Categories : PHP , Authentication , HTML and PHP , Sessions , Security A beginner's session handling class Categories : PHP , PHP Classes , Sessions , Beginner Guides A damaged image generator (class) for validating text.
CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart Categories : PHP , PHP Classes , Security , GD image library , Security Authenticator for Exchange Server LDAP Categories : PHP , Authentication , LDAP , Security , Sessions A login page that require username, password and userlevel. Categories : PHP , Security , Sessions , MySQL , Databases A very simple PHP single password cookie based login without usernames. Categories : PHP , Cookies , Security , Beginner Guides Function to generate readable/remeberable random password Categories : PHP , Security , Security A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page. Categories : PHP , Sessions , Security , Authentication Human readable PHP password generator Categories : PHP , Security , Beginner Guides , Arrays Session Validation Methods (Security Checks) Categories : PHP , Sessions , Security CAPTCHA[Image verification] Categories : PHP , Security , GD image library , Graphics , Sessions Dynamic Image Authentication System in Signup Pages (CAPTCHA) Categories : PHP , Security , GD image library