Location: PHPKode > scripts > Session Handler Class > session-handler-class/index.php
<?php
//This is an Example
  require('session_handle.php');
  //Start it
  //default set Constructor Vars FALSE
  $session_handle= new session_handler;
  //SESSION HANDLER
  // -> Constructor Variables
  //-> $session_handle= new session_handler(gc_maxlifetime, gc_probability,
  //                gc_divisor, session_save_path)
  //Session Table
  /*
   *  You need two tables:
   *  one SESSION Table Structur:
   *   
   *  session_id(VARCHAR)  | session_time(INT)  | session_value(TEXT) | session_user(VARCHAR(255))
   *  
   *  AND    cron_db for Cron-Job Activated
   *   
   *          ID | cron_date(varchar(16)) |
   *         ------------------------------- 
   *  Value:  1  | 000000000              |
   *  
   *____________________________________________________
   *
   *  Example Cron.php will do a SESSION DB update                     
   */   
  $session_handle->session_table='session_table';
  $session_handle->cron_db='cron_db';
  $session_handle->hostname="localhost";
  $session_handle->user='root'; 
  $session_handle->pass='';
  $session_handle->database='myproject';
  
  $session_handle->cron_php='cron.php';
  $session_handle->activate_cron=true;
  $session_handle->regenerate_id=true;
  $session_handle->save_in_db=true;
  $session_handle->execute();
    echo '<h3>SESSION Handler</h3>';
    echo '<h4>written by <a href="http://christianzinke.wordpress.com/">Christian Zinke</a></h4>';
    echo '<h4>BSD license</h4>';
    echo '<p>This Class Handles your Session Settings and do
    a Cron Job, Save Session AND regenerates ID if you wanne</p>'; 
    if(isset($_GET['logout']) AND $_GET['logout'] == 'true')
    {
      unset($_SESSION);
      session_destroy();
    }
    if(isset($_SESSION))
    {
      echo '<p>Session ID: '.session_id().'</p>';
      echo '<p>User Identifikation: '.$_SESSION['user_unique'].'</p>';
    }
    else
    {
      echo '<p>Session over</p>';
    }
    echo '<p>Lifetime: '.get_cfg_var("session.gc_maxlifetime").'</p>';
    echo '<p>Proability: '.get_cfg_var("session.gc_probability").'</p>';
    echo '<p>Divisor: '.get_cfg_var("session.gc_divisor").'</p>';
    
    echo '<p><a href="index.php?logout=true">Logout</a></p>';
    
    
?>
Return current item: Session Handler Class