2017 © Pedro Peláez
 

library pop-session

Pop Session Component for Pop PHP Framework

image

popphp/pop-session

Pop Session Component for Pop PHP Framework

  • Monday, January 29, 2018
  • by nicksagona
  • Repository
  • 1 Watchers
  • 1 Stars
  • 848 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 7 % Grown

The README.md

pop-session

Build Status Coverage Status, (*1)

Join the chat at https://discord.gg/TZjgT74U7E, (*2)

Overview

pop-session is a component used to manage sessions and session data in the PHP web environment. It includes the ability to also manage namespaces within the session as well as timed-based and request-based expirations., (*3)

pop-session is a component of the Pop PHP Framework., (*4)

Top, (*5)

Install

Install pop-session using Composer., (*6)

composer require popphp/pop-session

Or, require it in your composer.json file, (*7)

"require": {
    "popphp/pop-session" : "^4.0.2"
}

Top, (*8)

Quickstart

You can create a session and store and fetch data from it:, (*9)

use Pop\Session\Session;

$sess = Session::getInstance();

// Set session values
$sess->foo   = 'bar';
$sess['baz'] = 123;

// Access session values
echo $sess['foo'];
echo $sess->baz;

You can unset session data like this:, (*10)

unset($sess->foo);
unset($sess['baz']);

And finally, you can destroy the whole session like this:, (*11)

$sess->kill();

Top, (*12)

Time-Based

Session values can be made available based on time expiration:, (*13)

use Pop\Session\Session;

$sess = Session::getInstance();
$sess->setTimedValue('foo', 'bar', 10); // # of seconds

Then, the next request will be successful if it's within the time limit of that session data:, (*14)

use Pop\Session\Session;

if (isset($sess->foo)) {
    echo $sess->foo;
} else {
    echo 'Nope!';
}

Top, (*15)

Request-Based

Session values can be made available based on number of requests:, (*16)

use Pop\Session\Session;

$sess = Session::getInstance();
$sess->setRequestValue('foo', 'bar', 1); // # of requests

Then, the next request will be successful if it's within the set limit of number requests allowed before that session data is expired:, (*17)

if (isset($sess->foo)) {
    echo $sess->foo;
} else {
    echo 'Nope!';
}

Top, (*18)

Namespaces

You can store session data under a namespace to separate that data from the global session data:, (*19)

use Pop\Session\SessionNamespace;

$sessMyApp = new SessionNamespace('MyApp');
$sessMyApp->foo = 'bar'

if (isset($sessMyApp->foo)) {
    echo $sessMyApp->foo;  // Only available under the namespace.
} else {
    echo 'Nope!';
}

Session namespaces can also store time-based and request-based session data:, (*20)

use Pop\Session\SessionNamespace;

$sessMyApp = new SessionNamespace('MyApp');
$sessMyApp->setTimedValue('foo', 'bar', 10); // # of seconds
$sessMyApp->setRequestValue('foo', 'bar', 1); // # of requests

Top, (*21)

The Versions

29/01 2018

dev-master

9999999-dev http://www.popphp.org/

Pop Session Component for Pop PHP Framework

  Sources   Download

BSD-3-Clause New BSD

The Requires

  • php >=5.6.0

 

php session sessions pop pop php

29/01 2018

dev-v3-dev

dev-v3-dev http://www.popphp.org/

Pop Session Component for Pop PHP Framework

  Sources   Download

BSD-3-Clause New BSD

The Requires

  • php >=5.6.0

 

php session sessions pop pop php

29/01 2018

3.1.2

3.1.2.0 http://www.popphp.org/

Pop Session Component for Pop PHP Framework

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.6.0

 

php session sessions pop pop php

21/06 2017

3.1.1

3.1.1.0 http://www.popphp.org/

Pop Session Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.6.0

 

php session sessions pop pop php

22/02 2017

3.1.0

3.1.0.0 http://www.popphp.org/

Pop Session Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.6.0

 

php session sessions pop pop php

10/07 2016

3.0.1

3.0.1.0 http://www.popphp.org/

Pop Session Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

php session sessions pop pop php

10/07 2016

3.0.0

3.0.0.0 http://www.popphp.org/

Pop Session Component for Pop PHP Framework

  Sources   Download

New BSD

The Requires

  • php >=5.4.0

 

php sessions pop pop php