Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2024-10-15 (7 hours ago) | | Not enough user ratings | | Total: 25 This week: 25 | | All time: 11,214 This week: 1 |
|
Description | | Author |
This package can store PHP sessions in different types of storage.
It provides several session handler classes that store and retrieve PHP session data in different storage system types with an option to make session variables read-only, to avoid the variable can be changed.
The package provides a function to let developers set the preferred session handler.
Currently, it can store session data in:
- Files
- Redis server
- Memcached server
- MySQL database table | |
|
|
Innovation award
Nominee: 4x
Winner: 3x |
|
Details
Session Handlers
Collection of Mostly used Session Handlers
-
Supports File / MySql / Redis / Memcached based Session Handlers
-
Supports Readonly mode as well for all the above mentioned Session Handlers
Example
<?php
include __DIR__ . '/SessionHandlers/Session.php';
// Initialise Session Handler
Session::initSessionHandler('File');
// Session::initSessionHandler('MySql');
// Session::initSessionHandler('Redis');
// Session::initSessionHandler('Memcached');
// Start session in readonly mode
// Use when user is already logged in and we need to authorise the client cookie.
Session::start_readonly();
// Auth Check
if (!isset($_SESSION) || !isset($_SESSION['id'])) {
die('Unauthorised');
}
// Start session in normal (read/write) mode.
// Use once client is authorised and want to make changes in $_SESSION
Session::start_rw_mode();
$_SESSION['id'] = 1;
Database Table for MySql
CREATE TABLE IF NOT EXISTS `sessions` (
`sessionId` CHAR(32) NOT NULL,
`lastAccessed` INT UNSIGNED NOT NULL,
`sessionData` TEXT,
PRIMARY KEY (`sessionId`)
) ENGINE=InnoDB;
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.