#include your file
include './to/path/session-manager.php';
use Prog98rammer\Session\Session;
// start the session.
$session = new Session();
-- Basic Usage
-- First One
$session = new Session($prefix);
-- Example
$session = new Session('test_');
$session = new Session;
$session->prefix('test_')->set('name', 'khalid'); // it will set the session as "test_name"
$sesssion->getPrefix(); // will return the session prefix
$sesssion->all();
// store the new session
$session->set($key, $value);
// for Example
$session->set('name', 'John');
$session->set('name', 'Khalid')
->set('age', 19)
->set('country', 'Iraq')
->set('city', 'Baghdad');
$session->set([
'name' => 'khalid',
'age' => 19,
'location' => [
'country' => 'iraq',
'city' => 'baghdad'
]
]);
$sesssion->get($key); // will use the default prefix.
$session->fromPrefix($prefix);
#example
$session->fromPrefix('test'); // returns an array of all session that have a "test" prefix
Session::has($key); // returns True or False
#example
if(Session::has('is_loggin')) {
// do something
} else {
// do something else
}
$sesssion->remove($key);
$session->remove('name')
->remove('age')
->remove('location');
$session->remove([
'name', 'age', 'location'
]);
$session->remove('name', 'age', 'location');
$sesssion->id(); // will return the id of the session.
$sesssion->regenerate_id(); // will return the id of the session.
$session->destroy();