|Classes of Lars Moelleken||>||PHP Session MySQL Handler||>||README.md||>||Download|
A drop-in replacement for PHP's default session handler which stores session data in a database, providing both better performance and better security and protection against session fixation and session hijacking.
Session2DB implements session locking - a way to ensure that data is correctly handled in a scenario with multiple concurrent AJAX requests.
It is also a solution for applications that are scaled across multiple web servers (using a load balancer or a round-robin DNS) and where the user's session data needs to be available. Storing sessions in a database makes them available to all of the servers!
The library supports "flashdata" - session variable which will only be available for the next server request, and which will be automatically deleted afterwards. Typically used for informational or status messages (for example: "data has been successfully updated").
The code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL.
PHP 7.x with the mysqli extension activated, MySQL 5.x+ (recommanded: mysqlnd extension)
How to install
How to use
After installing, you will need to initialise the database table from the install directory from this repo, it will containing a file named session_data.sql. This file contains the SQL code that will create a table that is used by the class to store session data. Import or execute the SQL code using your preferred MySQL manager (like phpMyAdmin or the fantastic Adminer) into a database of your choice.
*Note that this class assumes that there is an active connection to a MySQL database and it does not attempt to create one!