2017 © Pedro Peláez
 

library session-muscle

Session provider component for ITCourses Jazz Framework

image

antonkalmykov/session-muscle

Session provider component for ITCourses Jazz Framework

  • Tuesday, February 16, 2016
  • by kalmykovanton
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

SessionMuscle

Session provider component for ITCourses Jazz Framework, (*1)

How to use:

Every time when there is a request to the server, SessionMuscle will start session automatically. To modify or save current session data use SessionMuscle API methods. Under session type understood long-term session or short-term session. By default, all sessions are short-term. The duration of the sessions, you can specify in the session settings. Depending of the session type, session essentially will end on short or long postfix. For example:, (*2)

63073ae80b786fdc21bb7616a54d25615e6c8f28short - name of short session, (*3)

or 27s45ae80b987fsc22bs4576v54d25615w6c8f28long - name of long session, (*4)

Garbage collector will start automatically, depending of 'runRate' session setting and session lifetime types., (*5)

NOTE: session repository must have read/write permissions., (*6)

First of all, create an array of settings for SessionMuscle component:, (*7)

// settings array
$settings = [
    // cookie name which will store the session id
    'cookieName' => 'sess',
    // session entity to record logs
    'sessLogName' => '.sesslog',
    // session repository in this case be folder,
    // generally it can be any
    'repository' => 'storage/sessions',
    // through a gap to run the garbage collector
    'runRate' => 10,
    // short session lifetime in seconds
    'short' => 60,
    // long session lifetime in seconds
    'long' => 120
];

Then, create adapter which will be responsible for maintaining sessions (in this example, this is adapter who stored sessions into files):, (*8)

use SessionMuscle\Adapters\FileAdapter;
$adapter = new FileAdapter();

And now you can create session instance, first argument is session adapter instance, second - session settings:, (*9)

use SessionMuscle\Session;
$session = new Session($adapter, $settings);

SessionMuscle API

Retrieve all data from the session:, (*10)

$session->all(); // return array of session data

Retrieve a value from the session. You may also pass a default value as the second argument to this method. This default value will be returned if the specified key does not exist in the session:, (*11)

$session->get($key, $default = ''); // return session data or default value

Add new data to current session:, (*12)

$session->put($key, $value); // return true on success

Check if an item exists in the session:, (*13)

$session->has($key); // return true if key exists or false if no

Retrieve a value from the session, and then delete it. You may also pass a default value as the second argument to this method. This default value will be returned if the specified key does not exist in the session:, (*14)

$session->pull($key, $default = ''); // return session data or default value.

Remove a piece of data from the session by given key:, (*15)

$session->delete($key, $default = ''); // true on successful removal or false if no

To get current session ID with session type (if exists), use:, (*16)

$session->getSessID(); // current session ID with session type

To get current repository, use:, (*17)

$session->getRepository();

To get current session cookie name, use:, (*18)

$session->getCookieName();

To get used session types, use:, (*19)

$session->getSessionTypes(); // return array of session types

To get current session type, use:, (*20)

$session->getSessionType(); // return current session type

To set type of current session, use:, (*21)

$session->setSessionType($sessionType);

To get current session settings, use:, (*22)

$session->getSessionSettings(); // return current session settings array

To save current session, use:, (*23)

$session->save();

To regenerate current session, use:, (*24)

$session->regenerate();

To completely remove current session, use:, (*25)

$session->clear();

The Versions

16/02 2016

dev-master

9999999-dev https://github.com/kalmykovanton/SessionMuscle.git

Session provider component for ITCourses Jazz Framework

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Anton Kalmykov

16/02 2016

v1.0.0

1.0.0.0 https://github.com/kalmykovanton/SessionMuscle.git

Session provider component for ITCourses Jazz Framework

  Sources   Download

MIT

The Requires

  • php >=5.5.9

 

by Anton Kalmykov