Session PHP(7+)
PHP Session Manager (non-blocking, flash, segment, session encryption). Uses PHP open_ssl for optional encrypt/decryption of session data.
Driver support Scope
[]()
Installation
You can download the Latest release version as a standalone, alternatively you can use Composer
$ composer require ghostff/session
"require": {
"ghostff/session": "^1.0"
}
Basic usage:
Registering Error Handler (optional)
#This method must be implemented before Session::start
Session::registerErrorHandler(function($error, $error_code)
{
#Debug::Log($error);
});
Setting or getting session id :void
#When setting ID, method must be implemented before Session::start
Session::id(bin2hex(random_bytes(32)));
#Get ID
echo Session::id();
Initializing Session
$session = Session::start($optional_session_namespace);
Using Segment :Segment
$segment = $session->segment($required_segment_name);
Setting Session Data
$session->name = 'foo';
# Setting Segment
$segment->name = 'bar';
# Setting Flash
$session->flash->name = 'foobar';
# Setting Segment Flash
$segment->flash->name = 'barfoo';
$session->commit();
Retrieving Session Data
echo $session->name; # outputs foo
# Retrieving Segment
echo $segment->name; # outputs bar
# Retrieving Flash
echo $session->flash->name; # outputs foobar
# Retrieving Segment Flash
echo $segment->flash->name; # outputs barfoo
Removing Session Data
$session->remove->name;
# Removing Segment
$segment->remove->name;
# Removing Flash
$session->remove->flash->name;
# Removing Segment Flash
$segment->remove->flash->name;
Retrieve all session or segment data :array
$session->all($optional_segment);
Check if variable exist in current session namespace :bool
$session->exist($variable_name, $option_segment, $in_flash);
Removing active session or segment data :void
$session->clear($optional_segment);
Destroying session :void
$session->destroy();
Regenerate session ID :void
$session->rotate($keep_old_session_data);