Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Logan Dugenoux  >  Session Lister  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of use of the class
Class: Session Lister
Lists all concurrent sessions off a site
Author: By
Last change: New sample for V1.1 of the class :
listing recent sessions only, and listing creation date, modification date of the sessions.
Date: 2003-11-06 09:04
Size: 857 bytes
 

Contents

Class file image Download
<?
require ("sessionLister.php");
$sl = new sessionLister();

// Example 1
//----------
// Count sessions younger than 1 hour
$recentCount 0;
foreach( 
$sl->getSessions() as $sessName => $sessData )
{
    if (
$sessData["age"]<3600)
        
$recentCount++;
}
echo 
$recentCount." sessions accessed within the last hour<br><br>";

// Example 2
//----------
// Display all the sessions and its data
echo $sl->getSessionsCount()." sessions available<br><br>";
foreach( 
$sl->getSessions() as $sessName => $sessData )
{
   echo 
"<hr>Session ".$sessName." :<br>";
   echo 
" Rawdata = ".$sessData["raw"]."<br>";
   echo 
" creation date = ".date"d/m/Y H:i:s",$sessData["creation"])."<br>";
   echo 
" last modif date = ".date"d/m/Y H:i:s",$sessData["modification"])."<br>";
   echo 
" age = ".round($sessData["age"]/3600/24,1)." days<br>";

}
?>