Implements \WebServCo\Framework\Interfaces\SessionInterface.
Both \WebServCo\Framework\AbstractController and \WebServCo\Framework\AbstractRepository contain the method session() which returns a single instance of the Session class.
This means you can use $this->session() in your Controller or Repository classes.
The Library is instantiated using the configuration file Session.php from your application's config directory.
To use the library in another place:
final public function session()
{
return \WebServCo\Framework\Framework::getLibrary('Session');
}$session = new \WebServCo\Framework\Libraries\Session($configurationArray);Note: session is not started in CLI mode.
In your Controller's __construct() method:
$this->session()->start($storagePath);$this->session()->start();$result = $this->session()->has('user/name');$this->session()->set($setting, $value);
$this->session()->set('user/name', 'Aria');$this->session()->add($setting, $data);
$this->session()->add('user/settings', 'setting1');
$this->session()->add('user/settings', 'setting2');
$this->session()->add('user/settings', 'setting3');The key remains in session storage, however the value will be null.
$this->session()->clear($setting);
$this->session()->clear('user/name');The key is deleted from session storage.
Use has() to check if the key exists before removing.
$this->session()->remove($setting);
$this->session()->remove('user/name');$this->session()->get($setting, $defaultValue = null);
$this->session()->get('user/name');
$this->session()->get('user/name', 'N/A');