Skip to content

Include this package in any PHP project to store encrypted $_SESSION variables in your MySQL database

License

Notifications You must be signed in to change notification settings

likel/php-simple-sessions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-simple-sessions

Include this package in any PHP project to store encrypted $_SESSION variables in your MySQL database

Getting Started

This package is designed to store PHP sessions in a MySQL database so that you can encrypt and access your site's active sessions.

Prerequisites

  • MySQL database
  • PHP 5.1 and above for use of PDO

Installing on your server

  1. Create a session table in your MySQL database by running install/setup.sql
CREATE TABLE `likel_sessions` (
    `id` char(128) NOT NULL DEFAULT '',
    `set_time` char(10) NOT NULL,
    `data` text NOT NULL,
    `session_key` char(128) NOT NULL,
    `iv` varchar(16) NOT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  1. Move the files under /src into a directory on your server such as "session"
e.g. session/ini, session/models, session/autoload.php, session/example.php
  1. Move the ini/credentials.ini file to a location not accessible by the public
e.g. $ mv ini/credentials /var/www/html/
  1. Update the database information in the credentials.ini file

  2. Ensure that when you create a new session you specify the new credentials.ini location

$session = new Likel\Session\Handler(array(
    'credentials_location' => "/path/to/new/credentials.ini"
));
  1. Run src/example.php and check your database for the newly created session

Running the tests

Run test/SessionHandlerTest.php with PHPUnit

$ phpunit SessionHandlerTest.php

Author

Liam Kelly - likel

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

Include this package in any PHP project to store encrypted $_SESSION variables in your MySQL database

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages