websoftwares / session
PHP 5.3+ Session Class that accepts optional save handlers.
Requires
- php: >=5.3.0
Requires (Dev)
- lboynton/memcached-json-session-save-handler: dev-master
- phpunit/phpunit: 3.7.*
Suggests
- lboynton/memcached-json-session-save-handler: Handy for reading the session in other languages.
README
PHP 5.3+ Session Class that accepts optional save handlers.
Installing via Composer (recommended)
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
Usage
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();
Options
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();
Start a new session.
$session->start();
destroy();
Destory the session.
$session->destroy();
close();
Close the session.
$session->close();
active();
Find out if their is a session active.
$session->active();
id($string);
Set session id, Get current/previous session id.
$session->id($string);
regenerate();
Regenerate session id, optional bool true for session deletion.
$session->regenerate();
ArryAccess
U can access the session object as an array.
$session["key"] = "value";
Testing
In the tests folder u can find several tests.
License
DBAD Public License.
Acknowledgement
All the great session managment solutions.