PHP 5.3+ Session Class that accepts optional save handlers.
Install composer in your project:
curl -s http://getcomposer.org/installer | php
Create a composer.json file in your project root:
{
"require": {
"websoftwares/session": "dev-master"
}
}
Install via composer
php composer.phar install
Basic usage of the Session
class.
use Websoftwares\Session;
// Instantiate class
$session = new Session;
// Start session
$session->start();
// Store in session
$session["key"] = 'value';
var_dump($_SESSION);
// Destroy
$session->destroy();
U can override the default options by instantiating a Session
class and pass in an array as the second argument.
$options = array(
// If enabled (default) extra meta data is added (name,created,updated)
'meta' => true,
// Provide custom session name
'name' => null,
'lifetime' => 0,
'path' => '/',
'domain' => null,
'secure' => true,
'httponly' => false
);
// Instantiate class
$session = new Session(null,$options);
Start a new session.
$session->start();
Destory the session.
$session->destroy();
Close the session.
$session->close();
Find out if their is a session active.
$session->active();
Set session id, Get current/previous session id.
$session->id($string);
Regenerate session id, optional bool true for session deletion.
$session->regenerate();
U can access the session object as an array.
$session["key"] = "value";
In the tests folder u can find several tests.
DBAD Public License.
All the great session managment solutions.