rawphp/raw-session

RawSession provides application session service, including flash messages and is used by RawPHP framework and other applications.

dev-master / 0.x-dev 2014-12-24 05:12 UTC

This package is auto-updated.

Last update: 2024-04-20 07:59:54 UTC


README

Build Status Coverage Status

Latest Stable Version Total Downloads Latest Unstable Version License

Package Features

  • Easily manage sessions with start(), close(), destroy() and recreate()
  • Manage data persistence across requests with add(), get(), remove()

Installation

Composer

RawSession is available via Composer/Packagist.

Add "rawphp/raw-session": "0.*@dev" to the require block in your composer.json and then run composer install.

{
        "require": {
            "rawphp/raw-session": "0.*@dev"
        }
}

You can also simply run the following from the command line:

composer require rawphp/raw-session "0.*@dev"

Tarball

Alternatively, just copy the contents of the RawSession folder into somewhere that's in your PHP include_path setting. If you don't speak git or just want a tarball, click the 'zip' button at the top of the page in GitHub.

Basic Usage

<?php

use RawPHP\RawSession\Session;

// optional configuration
$config = array(
    'auto_start' => FALSE,  // should the session be started automatically
    'strict'     => TRUE,   // throw exceptions if there are problems with the session
);

// create a new session instance
$session = new Session( );

// initialise
$session->init( $config );

// start session
$session->start( );

// get session ID
$id     = $session->getID( );

// get session status
$status = $session->getStatus( );

// add a value to the session
$session->add( 'user_id', 1 );

// get a value from the session
$userID = $session->get( 'user_id' );

// remove value from the session
$session->remove( 'user_id' );

// destroy the session
$session->destroy( );

// destroy and start a new session
$session->recreate( );

License

This package is licensed under the MIT. Read LICENSE for information on the software availability and distribution.

Contributing

Please submit bug reports, suggestions and pull requests to the GitHub issue tracker.

Changelog

22-09-2014

  • Tested with PHP 5.3.

20-09-2014

  • Replaced php array configuration with yaml

18-09-2014

  • Updated to work with the latest rawphp/rawbase package.

17-09-2014

  • Updated to work with the latest rawphp/rawbase package.

14-09-2014

  • Fixed bug in Session.php.

13-09-2014

  • Added the hook system

11-09-2014

  • Initial Code Commit