2017 © Pedro Peláez
 

library sessions

Sessions

image

xp-forge/sessions

Sessions

  • Friday, June 8, 2018
  • by thekid
  • Repository
  • 1 Watchers
  • 0 Stars
  • 270 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 125 % Grown

The README.md

Sessions for the XP Framework

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.4+ Supports PHP 8.0+ Latest Stable Version, (*1)

Example

use web\session\{InFileSystem, ForTesting};

// Instantiate session factory
$sessions= new InFileSystem('/tmp');
$sessions= (new ForTesting())->lasting(3600)->named('psessionid');

// Create a new session
$session= $sessions->create();

// Open an existing session...
if ($session= $sessions->open($sessionId)) { … }

// ...or locate session attached to a request
if ($session= $sessions->locate($request)) { … }

// Basic I/O operations
$session->register('key', 'value');
$value= $session->value('key');
$keys= $session->keys();
$session->remove('key');

// Destroy
$session->destroy();

// Close session...
$session->close();

// ...or close and then transmit session to response.
$session->transmit($response);

Ensure you always either call close() or transmit() to have the session data synchronized., (*2)

Implementations

This library includes the following implementations:, (*3)

  • web.session.InFileSystem - using the local filesystem with serialized data
  • web.session.ForTesting - in-memory sessions, for testing purposes

Other implementations provide solutions for clustering:, (*4)

  • https://github.com/xp-forge/redis-sessions
  • https://github.com/xp-forge/mongo-sessions
  • https://github.com/xp-forge/cookie-sessions

Secure

The Secure flag is set for all session cookies. If you develop on localhost using http only, you will need to tell the sessions instance as follows:, (*5)

// This will omit the "Secure" flag from session cookies in dev environment
$sessions= new InFileSystem('/tmp');
if ('dev' === $this->environment->profile()) {
  $sessions->cookies()->insecure(true);
}

The Versions

08/06 2018

dev-master

9999999-dev http://xp-framework.net/

Sessions

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

05/06 2018

v0.3.0

0.3.0.0 http://xp-framework.net/

Sessions

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

29/05 2018

v0.2.0

0.2.0.0 http://xp-framework.net/

Sessions

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp

10/05 2018

v0.1.0

0.1.0.0 http://xp-framework.net/

Sessions

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

module xp