PHP Classes

File: example.php

Recommend this page to a friend!
  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: 15 years ago
Size: 1,204 bytes


Class file image Download
// make the require to the classe "session"
// starts session object
$Sess = new session();

// connection to mysql DB
$conn = mysql_connect("localhost","root","");
$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

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
// 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";

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