joefallon/phpsession

A simple age and activity based session library.

v4.0.1 2016-07-13 21:27 UTC

This package is auto-updated.

Last update: 2024-10-25 23:39:33 UTC


README

By Joe Fallon

This library has the following features:

  • Fully unit tested.
  • Does not keep the session open between reads and writes. This allows AJAX requests to not be blocked.
  • Simple to use. Can be fully understood in a matter of minutes.
  • Allows a maximum age to be used for session invalidation.
  • Allows a maximum inactivity time to be used for session invalidation.

Installation

The easiest way to install PHP Scalars is with Composer. Create the following composer.json file and run the php composer.phar install command to install it.

{
    "require": {
        "joefallon/phpsession": "*"
    }
}

Usage

$foo     = 'bar';
$session = new Session();
$session->write($foo, 'value');
$session->read($foo);   // value

The Session class contains the following methods:

__construct($maxAgeInSecs = 1800, $lastActivityTimeoutInSecs = 1800)
read($key)
write($key, $val)
unsetSessionValue($key)
maxAgeTimeoutExpired()
lastActivityTimeoutExpired()
destroy()