/nb-sessions

Non-Blocking-Sessions made easy

Primary LanguagePHPApache License 2.0Apache-2.0

NbSessions

Build Status Coverage Status Latest Stable Version Total Downloads License

A non-blocking session handler for PHP. This library is inspired by duncan3dc/sessions.

Examples

basic

$session = new \NbSessions\SessionInstance('my-app');
$session->set('login', 'jdoe');
$login = $session->get('login');

namespaces

To avoid key collisions you can use namespaces.

$session->set('foo', 'bar');

$namespace = $session->getNamespace('my-module');
$namespace->set('foo', 'baz');

$session->get('foo'); // 'bar'
$namespace->get('foo'); // 'baz'

static class

For easier access you can use the static class. But remember: it's more hard to test.

$namespace = \NbSessions\Session::getNamespace('my-module');
\NbSessions\Session::get('foo');

Setup

Install it via composer and use without configuration.

composer require tflori/nb-sessions

Read the docs for more information.