This module was designed as a wrapper so it could be injected into the pimple. It can also be used another way. For example, you can call the class directly and call any function statically to achieve the same result. It uses the native $_SESSION[] session variable array. We suggest you use this through pimple's dependency injector.
There are two ways you can install this module. By using composer or by downloading directly, but if you download it directly and requires more steps you can view all the available downloads at https://github.com/Awixe/Session/releases so we recommend you use composer to make it simple.
With composer:
composer require awixe/sessionIf you are using the awixe module adapter than you can access it through the app function else if you are not use the awixe adapter then you have to declare a new object to use it.
Example #1:
<?php// Require composerrequire__DIR__ . '/vendor/autoload.php';
// Not required if the bootstrap file is requiredsession_start();
// Set a new session variableapp('session')->set('hello', 'world');
// Get a session variableif (app('session')->get('hello')) {
// Save result$output = [
app('session')->get('hello')
];
}
// Delete a session variableapp('session')->del('hello');
// Print the resultprint_r($output);
if (app('session')->get('hello')) {
print(app('session')->get('hello'));
} else {
var_dump(app('session')->get('hello'));
}
?>Example #2:
<?php// Require composerrequire__DIR__ . '/vendor/autoload.php';
useAwixe\Module\Session\Handler;
// Not required if the bootstrap file is requiredsession_start();
// Declare a new object$session = newHandler();
// Set a new session variable$session->set('hello', 'world');
// Get a session variableif ($session->get('hello')) {
// Save result$output = [
$session->get('hello')
];
}
// Delete a session variable$session->del('hello');
// Print the resultprint_r($output);
if ($session->get('hello')) {
print($session->get('hello'));
} else {
var_dump($session->get('hello'));
}
?>- Framework: https://github.com/Awixe/Framework
- Issues: https://github.com/Awixe/Session/issues