websoftwares/session

PHP 5.3+ Session Class that accepts optional save handlers.

0.1.1 2013-08-26 07:34 UTC

This package is auto-updated.

Last update: 2024-04-15 02:31:57 UTC


README

PHP 5.3+ Session Class that accepts optional save handlers.

Build Status

Installing via Composer (recommended)

Install composer in your project:

curl -s http://getcomposer.org/installer | php

Create a composer.json file in your project root:

{
    "require": {
        "websoftwares/session": "dev-master"
    }
}

Install via composer

php composer.phar install

Usage

Basic usage of the Session class.

use Websoftwares\Session;

// Instantiate class
$session = new Session;

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

// Store in session
$session["key"] = 'value';

var_dump($_SESSION);

// Destroy
$session->destroy();

Options

U can override the default options by instantiating a Session class and pass in an array as the second argument.

$options = array(
    // If enabled (default) extra meta data is added (name,created,updated)
    'meta' => true,
    // Provide custom session name
    'name' => null,
    'lifetime' => 0,
    'path' => '/',
    'domain' => null,
    'secure' => true,
    'httponly' => false
);

// Instantiate class
$session = new Session(null,$options);

start();

Start a new session.

$session->start();

destroy();

Destory the session.

$session->destroy();

close();

Close the session.

$session->close();

active();

Find out if their is a session active.

$session->active();

id($string);

Set session id, Get current/previous session id.

$session->id($string);

regenerate();

Regenerate session id, optional bool true for session deletion.

$session->regenerate();

ArryAccess

U can access the session object as an array.

$session["key"] = "value";

Testing

In the tests folder u can find several tests.

License

DBAD Public License.

Acknowledgement

All the great session managment solutions.