PHP Classes

File: test_simple_session.php

Recommend this page to a friend!
  Classes of Sunny Rajpal   SimpleSession   test_simple_session.php   Download  
File: test_simple_session.php
Role: Example script
Content type: text/plain
Description: This shows how to use the SimpleSession Class
Class: SimpleSession
A very simple session handeling class
Author: By
Last change: changed description
Date: 22 years ago
Size: 1,981 bytes
 

Contents

Class file image Download
<html>
<head>
<title>Test Session Class</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<?
   
include("./SimpleSession.php");
   
$S = new Session;
   
   
//turn off automatic update
    //this is so we can test these things out
   
$S->SetUpdate(false);
   
//set the timeout to 5 seconds
   
$S->SetTimeOut(5);
   
    echo
"Check for session \"A\": ";
    if (
$S->SessionExist("A"))
        echo
"Found!<br>";
    else
        echo
"Not Found! (".$S->GetRecentError().")<br>";
   
    echo
"Create session B (5 second timeout)...<br>";
    if (
$S->SessionStart("B"))
        echo
"Session B Created<br>";
    else
        echo
"Error: ".$S->GetRecentError()."<br>";
   
    echo
"Check for session \"B\": ";
    if (
$S->SessionExist("B"))
        echo
"Found!<br>";
    else
        echo
"Not Found! (".$S->GetRecentError().")<br>";
   
    echo
"Sleeping for 3 seconds...<br>";flush();
   
sleep(3);
    echo
"Time Remaining For Session \"B\": ";
   
$Tmp = $S->GetTimeRemaining("B");
    if (
$Tmp == -1)
        echo
"<br>Error: ".$S->GetRecentError()."<br>";
    else
        echo
"$Tmp Seconds"."<br>";
   
    echo
"Sleeping for 3 seconds...<br>";flush();
   
sleep(3);
    echo
"Time Remaining For Session \"B\": ";
   
$Tmp = $S->GetTimeRemaining("B");
    if (
$Tmp == -1)
        echo
"<br>Error: ".$S->GetRecentError()."<br>";
    else
        echo
"$Tmp Seconds"."<br>";
   
    echo
"Creating Session C...<br>";
    if (
$S->SessionStart("C"))
        echo
"Session C Created<br>";
    else
        echo
"Error: ".$S->GetRecentError()."<br>";
    echo
"Check for session \"C\": ";
    if (
$S->SessionExist("C"))
        echo
"Found!<br>";
    else
        echo
"Not Found! (".$S->GetRecentError().")<br>";
    echo
"Deleting Session C: ";
    if (
$S->SessionDestroy("C"))
        echo
"Success!<br>";
    else
        echo
"Failed! (".$S->GetRecentError().")<br>";
    echo
"Check for session \"C\": ";
    if (
$S->SessionExist("C"))
        echo
"Found!<br>";
    else
        echo
"Not Found! (".$S->GetRecentError().")<br>";
   
?>
</body>
</html>