daedalus-web/sessions

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v2.0.0) of this package.

Session handler module for the Daedalus web framework

v2.0.0 2017-08-11 16:30 UTC

This package is not auto-updated.

Last update: 2021-10-04 19:28:50 UTC


README

Build Status Scrutinizer Code Quality Packagist version Code Coverage

Session handler module for the Daedalus web application framework.

Installation

This module is typically used as part of a Daedalus web application. If you'd like to use it on your own non-Daedalus project, you can add the following to your composer.json file:

{
  "require": {
    "daedalus-web/sessions": "^1.0"
  }
}

Usage

This module handles Sessions.

// Create a new Session
$session = new Daedalus\Sessions\Session();
Session::start();


// Writing to the session
Session::add('oauth_token', 'abcd12345');
$token = Session::get('oauth-token');

// Closing or Destroying the session
Session::finish();
Session::clear();

Storage Methods && Extending Sessions

Currently we only support MySQL via POD using the \Daedalus\Database module. You can extend this module by adding a new class file to src/Daedalus/Sessions/Handlers to act as a new handler. Your handler must have the following class methods, each which returns a bool value (except read, which returns a string):

open Purpose: Creates any needed file structure/software connections. Returns: bool

close Purpose: Cleans up anything you don't want to linger after a session_destroy() such as database connections. Returns: bool

read Purpose: Reads from your storage medium and returns the $data that has been saved or an empty string if no data found. Returns: string

write Purpose: Writes the session data to your storage medium. Returns: bool

destroy Purpose: Deletes the session with the given $id from your storage medium. Returns: bool

gc Purpose: Deletes all sessions saved to your storage medium that have not been accessed in the last $maxlife seconds. Returns: bool

Session Hierarchy

All session information is stored inside of $\_SESSION['daedalus']. This ensures that any information that you add to Session does not clash with other non-Daedalus Session values. Session information should be stored in a namespaced manner with the module name appended to the key with a hyphen (ie: $\_SESSION['daedalus']['authentication-method'])

Multi-dimensional arrays are not currently supported, however you CAN save an associative array with Session::add() and then return the array with Session::get().

About

Requirements

Daedalus Sessions is fully tested to work with:

  • PHP 7.0
  • PHP 7.1

Strictly speaking, this module can be modified to support PHP 5.5+, however we use strict variable typing that is not available in PHP versions before 7.0. Because PHP 5.6 is no longer receiving active support (and will only be receiving security updates for another year), we strongly recommend starting any new project with PHP 7 or later.

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Author

Josh Grancell - josh@joshgrancell.com - https://github.com/jgrancell

License

Daedalus Sessions is licensed under the MIT License - see the LICENSE file for details