GithubHelp home page GithubHelp logo

likel / php-simple-sessions Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 532 KB

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

License: MIT License

PHP 100.00%
session php mysql store encrypted session-handler session-storage database

php-simple-sessions's Introduction

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

php-simple-sessions's People

Contributors

likel avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

futureup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.