Pop Session Component
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE.TXT
README.md
composer.json

README.md

pop-session

OVERVIEW

pop-session is a component used to manage and manipulate sessions in the PHP web environment.

pop-session is a component of the Pop PHP Framework.

INSTALL

Install pop-session using Composer.

composer require popphp/pop-session

BASIC USAGE

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;

// Unset session values
unset($sess->foo);
unset($sess['baz']);

// Kill/clear out the session
$sess->kill();

ADVANCED USAGE

Session values available based on time expiration:
use Pop\Session\Session;

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

if (isset($sess->foo)) {
    echo $sess->foo;
} else {
    echo 'Nope!';
}
Session values available based on number of requests:
use Pop\Session\Session;

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

if (isset($sess->foo)) {
    echo $sess->foo;
} else {
    echo 'Nope!';
}
Session values available based on number of namespace:
use Pop\Session\SessionNamespace;

$sess = new SessionNamespace(__NAMESPACE__);
$sess->foo = 'bar'

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