|
Session Class
To use Session Class v1.0.2 you will need PHP4+ and MySQL 3+. The example.php code will show you how to use the class
with simple hard link authentication. The MySQL table specifications are included in readme.txt.
example.php <?php
/***************************************************************************
* example.php v1.0.2
* -------------------
* begin : January 10, 2006
* last mod : January 10, 2006
* copyright : (C) 2005 BSG Online Games
* author: : Bryan Wiebe
* email : freelance@bsgonlinegames.com
*
* version: 1.0.2
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* http://www.gnu.org/licenses/gpl.txt
*
***************************************************************************/
// This example file will show you how to use session.class.php.
// Load the class
require_once("session.class.php");
= new bsg_session();
// Connect to MySQL database
$db = mysql_connect("localhost", "user", "password");
$r = mysql_select_db("database");
// This is referred to from below
// It handles logins
if ($_GET["login"]) {
// Authenticate the user
if ($_GET["user"] == "admin" && $_GET["password"] == "admin") {
$session->MakeSession("admin", $db);
$sessionfound = true;
}
} else {
// Get session from $_COOKIE["session"];
$sessionfound = $session->UseSession($db);
}
if ($sessionfound) {
// Session was found
echo "This is the secure members only area.";
} else {
// Show login form
echo "<form method=\"post\" action=\"?login=1\">\n";
echo "<form method=\"post\" action=\"?login=1\">\n";
echo "Username: <input name=\"user\" type=\"text\" /><br />\n";
echo "Password: <input name=\"password\" type=\"password\" /><br />\n";
echo "<input type=\"submit\" value=\"Login\" />\n";
echo "</form>\n";
}
?>
|
Network
Products & Services
|