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:

  1. class.DB_eSession.php - Main class file.
  2. errors.DB_eSession.php - Error and warning definitions used by class.
  3. config.DB_eSession.php - Optional configuration file used to pass parameters to class.
  4. eSessions_table.sql - A text file containing the SQL to create the MySQL sessions table.
  5. index.php - An example home page of an authentication process.
  6. login.php - An example page used to login members.
  7. emplogin.php - An example page used to login employees.
  8. logout.php - An example page of logging out members.
  9. members.php - An example page of members restricted area.
  10. employees.php - An example page of employees restricted area.
  11. guess.php - A number guessing game showing an example of the use of the class.
  12. examples.php - View code to get an idea of how to invoke various member functions of the class.
  13. monitor.php - Session table monitoring and maintenance page (helpful while testing your scripts).
  14. manual.html - DB_eSession class manual in HTML.
  15. license.html - The GPL in HTML.
  16. readme.html - This brief instructions file.

Basic installation steps (for more details refer to the '
How to install' section of the manual):

  1. 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.
  2. Use the SQL within the eSessions_table.sql file to create the sessions table (using phpMyAdmin).
  3. 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.
  4. 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.
  5. Open up your web browser and type the URL to point to the example PHP file you wish to run. i.e. or (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.