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 José Augusto Ferreira Franco  >  PHP Session  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: This file shows how to use the classe Session
Class: PHP Session
Manage session data
Author: By
Last change:
Date: 2008-01-17 11:20
Size: 1,204 bytes
 

Contents

Class file image Download
<?php
// make the require to the classe "session"
require_once("class_session.php");
// starts  session object
$Sess = new session();

// connection to mysql DB
$conn mysql_connect("localhost","root","");
mysql_select_db("session",$conn);
$rs mysql_query("SELECT * FROM sess_users");
$num mysql_num_rows($rs);

//read some values from database
while($line mysql_fetch_array($rs)){
$login[] = $line["login"];
$pass[] = $line["password"];
// stores it in an array
$arrSess array_combine($login,$pass);
}
// registering values
$Sess->register_session($arrSess);





/**
Checking if session was started
**/
if($_SESSION["guto"]){  // test it with an value on line login from mysql table
echo "Session were correctly started <br>";}

// generates the xml file
$Sess->LogSess2Xml();
// reads sessions from xml file
$arr $Sess->LoadSessfromXml();
// counts number of open sessions
// you can use it as a users counter on your web site
echo "There are currently " .(count($arr))." sessions open";

echo 
"<pre>";   // printign all session information  on xml file
echo" &nbsp;Session ---- Session variable <br/>";
print_r($arr);
echo 
"</pre>";





?>