Brief Instructions on the DB_eSession PHP class
This is a short introduction to the feature packed DB_eSession PHP class, which allows the storage and management of session data in a MySQL database rather than files (which is PHP's default). It is powerful, designed with security in mind, and easy to utilize. It's free under the GNU GPL.
Files included in this package:
- class.DB_eSession.php - Main class file.
- errors.DB_eSession.php - Error and warning definitions used by class.
- config.DB_eSession.php - Optional configuration file used to pass parameters to class.
- eSessions_table.sql - A text file containing the SQL to create the MySQL sessions table.
- index.php - An example home page of an authentication process.
- login.php - An example page used to login members.
- emplogin.php - An example page used to login employees.
- logout.php - An example page of logging out members.
- members.php - An example page of members restricted area.
- employees.php - An example page of employees restricted area.
- guess.php - A number guessing game showing an example of the use of the class.
- examples.php - View code to get an idea of how to invoke various member functions of the class.
- monitor.php - Session table monitoring and maintenance page (helpful while testing your scripts).
- manual.html - DB_eSession class manual in HTML.
- license.html - The GPL in HTML.
- readme.html - This brief instructions file.
Basic installation steps (for more details refer to the 'How to install' section of the manual):
- Use phpMyAdmin or similar tool to create a MySQL database, username and password. If you already have these defined/setup then you can use those if you wish and can skip this step.
- Use the SQL within the eSessions_table.sql file to create the sessions table (using phpMyAdmin).
- Update config.DB_eSessions.php with the name of the local host, database, username, password, table name, and column names if they are different than the supplied defaults.
- Install the class.DB_eSession.php, errors.DB_eSession.php, and config.DB_eSession.php in a folder on your web server (and make sure the files and folder have the correct permissions). Optionally, you can install the examples.php, guess.php, monitor.php, and the six login/logout example files to test the class with. Otherwise, you can just start writing your own script utilizing the new class.
- Open up your web browser and type the URL to point to the example PHP file you wish to run. i.e. www.example.com/guess.php or www.example.com/auth/index.php (this is assuming that you created a directory called 'auth' and placed the six login/logut example files and the class related files in it).
The monitor.php file allows you to view every row in the sessions table, lock/unlock, and delete sessions. It is intended as an aid while developing your scripts. Although it is useful for web masters to monitor session traffic, it is not recommend to place in a public directory (in a production ready site). If you still intend to use it in a public directory, then protect the page (like with a username and password) from easy access. If you're using an Apache server, you can protect the page by setting a .htaccess file. Also, read the Apache authentication information page.
Don't forget to read the DB_eSession class manual.