2017 © Pedro Peláez
 

library session

Bare bones drop in replacement for native PHP sessions with alternate storage repositories

image

syntactical/session

Bare bones drop in replacement for native PHP sessions with alternate storage repositories

  • Wednesday, December 2, 2015
  • by craigballinger
  • Repository
  • 1 Watchers
  • 1 Stars
  • 32 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

PHP Session Handler

This library is a drop in replacement for PHP's native session handling. It exposes an interface for alternate storage repositories using the SessionHandler class introduced in 5.4., (*1)

Usage

Install the library using composer, (*2)

composer install syntactical/session

Using a PDO MySQL session store

Create the table:, (*3)

CREATE TABLE `sessions` (
  `id` varchar(40) NOT NULL DEFAULT '0',
  `ip` int(10) NOT NULL DEFAULT '0',
  `user_agent` varchar(50) NOT NULL,
  `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
  `data` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `last_activity` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Bootstrap the library:, (*4)

$db = new PDO('mysql:host=your.db.host;dbname=db','username','password');
$table = 'sessions';
$storage = new MySQLStorage($db, $table);
$handler = new Session($storage);

session_set_save_handler($handler, true);
session_start();

You can now use the $_SESSION superglobal and session_* functions as you would natively, but sessions will be stored in MySQL rather than the filesystem., (*5)

The Versions

02/12 2015

dev-master

9999999-dev https://github.com/craigballinger/php-session

Bare bones drop in replacement for native PHP sessions with alternate storage repositories

  Sources   Download

The Requires

  • php >=5.4.0

 

by Craig Ballinger

02/12 2015

1.0.0

1.0.0.0 https://github.com/craigballinger/php-session

Bare bones drop in replacement for native PHP sessions with alternate storage repositories

  Sources   Download

The Requires

  • php >=5.4.0

 

by Craig Ballinger