PHP Classes

File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/ch08_User_and_Ses_Tracking/expire.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/glomodul/z_examples/book_video/03steinmetz_2008/ch08_User_and_Ses_Tracking/expire.php  >  Download  
File: fwphp/glomodul/z_examples/book_video/03steinmetz_2008/ch08_User_and_Ses_Tracking/expire.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change:
Date: 3 months ago
Size: 673 bytes
 

Contents

Class file image Download
<?
function login_validate() {
   
/* reset the timeout on a login session */
    /* default timeout is ten minutes (600 seconds) */
   
$timeout = 600;
   
$_SESSION["expires_by"] = time() + $timeout;
}

function
login_check() {
    @
session_start();
   
/* checks for session activity timeout */
   
$exp_time = intval($_SESSION["expires_by"]);
    if (
time() < $exp_time) {
   
/* session still valid; refresh the time */
   
login_validate();
    return
true;
    } else {
   
/* session expired; remove session variable */
   
unset($_SESSION["expires_by"]);
    return
false;
    }
}

session_start();

if (!
login_check()) {
   
header("Location: login.php");
    exit(
0);
}

?>

For more information send a message to info at phpclasses dot org.