middlewares/php-session

Middleware to start php sessions using the request data

v1.2.0 2018-08-04 10:41 UTC

README

Latest Version on Packagist Software License Build Status Quality Score Total Downloads SensioLabs Insight

Middleware to start a php session using the request data and close it after return the response.

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/php-session.

composer require middlewares/php-session

Example

$dispatcher = new Dispatcher([
	new Middlewares\PhpSession(),

    function () {
        //Use the global $_SESSION variable to get/set data
        $_SESSION['name'] = 'John';
    }
]);

$response = $dispatcher->dispatch(new ServerRequest());

Options

name(string $name)

The session name. If it's not provided, use the php's default

id(string $id)

The session id. If it's not provided, try to get it from the request's cookies.

options(array $options)

Array of options passed to session_start()

regenerateId(int $interval, string $key = 'session-id-expires')

The session id regeneration interval in seconds. If it's 0 or not provided, sesson ID will remain unchanged.

The session id expiry timestamp key name.

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.