2017 © Pedro Peláez
 

library php-session

Middleware to start php sessions using the request data

image

middlewares/php-session

Middleware to start php sessions using the request data

  • Saturday, May 12, 2018
  • by oscarotero
  • Repository
  • 2 Watchers
  • 3 Stars
  • 543 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 1 % Grown

The README.md

middlewares/php-session

Latest Version on Packagist ![Software License][ico-license] Testing ![Total Downloads][ico-downloads], (*1)

Middleware to start a php session using the request data and close it after returning the response. Reads and writes session cookies in the PSR-7 request/response., (*2)

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/php-session., (*3)

composer require middlewares/php-session

Example

Dispatcher::run([
    new Middlewares\PhpSession(),

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

Usage

This is a middleware to start the native PHP session using the cookies of the server request., (*4)

name

The session name. If it's not provided, use the php's default name (PHPSESSID). More info session_name, (*5)

// Start the session with other name
$session = (new Middlewares\PhpSession())->name('user_session');

id

This option set a session id. If it's not provided, use the request's cookies to get it., (*6)

// Start the session with a specific session id
$session = (new Middlewares\PhpSession())->id('foo');

options

This allows to set an of options passed to session_start(), (*7)

// Start the session with a specific session id
$session = (new Middlewares\PhpSession())->options([
    'cookie_lifetime' => 86400
]);

regenerateId

This option regenerates the id after a specific time interval. The latest regeneration time is saved in the key session-id-expires but you can change it in the second argument:, (*8)

// Regenerate the session id after 60 seconds
$session = (new Middlewares\PhpSession())->regenerateId(60);

// Regenerate the session id after 60 seconds, storing the expires date in the key 'expiresAt'
$session = (new Middlewares\PhpSession())->regenerateId(60, 'expiresAt');

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details., (*9)

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

The Versions

12/05 2018

dev-master

9999999-dev https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

12/05 2018

v1.1.0

1.1.0.0 https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

27/01 2018

v1.0.0

1.0.0.0 https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

13/11 2017

v0.6.0

0.6.0.0 https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

21/09 2017

v0.5.0

0.5.0.0 https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

18/04 2017

v0.4.0

0.4.0.0 https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

26/12 2016

v0.3.0

0.3.0.0 https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

27/11 2016

v0.2.0

0.2.0.0 https://github.com/middlewares/php-session

Middleware to start php sessions using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15

08/10 2016

v0.1.0

0.1.0.0 https://github.com/middlewares/php-session

Middleware to create a php session using the request data

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 server http session psr-15