Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tflori/nb-sessions
Non-Blocking-Sessions made easy
https://github.com/tflori/nb-sessions
Last synced: about 1 month ago
JSON representation
Non-Blocking-Sessions made easy
- Host: GitHub
- URL: https://github.com/tflori/nb-sessions
- Owner: tflori
- License: apache-2.0
- Created: 2017-02-01T05:41:48.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-18T11:35:01.000Z (about 1 year ago)
- Last Synced: 2024-04-13T03:22:27.960Z (9 months ago)
- Language: PHP
- Size: 43 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NbSessions
[![Build Status](https://travis-ci.org/tflori/nb-sessions.svg?branch=master)](https://travis-ci.org/tflori/nb-sessions)
[![Coverage Status](https://coveralls.io/repos/github/tflori/nb-sessions/badge.svg)](https://coveralls.io/github/tflori/nb-sessions)
[![Latest Stable Version](https://poser.pugx.org/tflori/nb-sessions/v/stable.svg)](https://packagist.org/packages/tflori/nb-sessions)
[![Total Downloads](https://poser.pugx.org/tflori/nb-sessions/downloads.svg)](https://packagist.org/packages/tflori/nb-sessions)
[![License](https://poser.pugx.org/tflori/nb-sessions/license.svg)](https://packagist.org/packages/tflori/nb-sessions)A non-blocking session handler for PHP. This library is inspired by
[duncan3dc/sessions](https://github.com/duncan3dc/sessions).## Examples
### basic
```php
$session = new \NbSessions\SessionInstance('my-app');
$session->set('login', 'jdoe');
$login = $session->get('login');
```### namespaces
To avoid key collisions you can use namespaces.
```php
$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.
```php
$namespace = \NbSessions\Session::getNamespace('my-module');
\NbSessions\Session::get('foo');
```## Setup
Install it via composer and use without configuration.
```bash
composer require tflori/nb-sessions
```Read [the docs](https://tflori.github.io/nb-sessions) for more information.