vakata/session

A simple key-value storage class

3.0.1 2024-02-19 16:20 UTC

This package is auto-updated.

Last update: 2024-05-19 16:53:57 UTC


README

Latest Version on Packagist Software License

A simple key-value storage class. used for configurations and extended in vakata/session.

Install

Via Composer

$ composer require vakata/session

Usage

Using the $_SESSION superglobal is perfectly fine and works well with this class.

$session = new \vakata\session\Session(); // autostarts session and applies useful defaults
$session->get('value'); // same as $_SESSION['value'];
$session->set('val.ue', 2); // same as $_SESSION['val'] = [ 'ue' => 1 ];
$session->del('value'); // same as unset($_SESSION['value']);
// optionally sessions can be stored in a database
$sessionDB = new \vakata\session\Session(
    true, // autostart
    new \vakata\sessions\handler\SessionDatabase(
        new \vakata\database\DB('mysqli://user:pass@host/database'),
        'table'
    )
);
// optionally sessions can be stored in memcached / filecache / database
$sessionDB = new \vakata\session\Session(
    true, // autostart
    new \vakata\sessions\handler\SessionCache(
        new \vakata\cache\Memcache(),
        'namespace' // this allows easy clearing
    )
);

For more on setting, getting and deleting values read here: https://github.com/vakata/kvstore

For more on the database class read here: https://github.com/vakata/database

For more on the memcached class read here: https://github.com/vakata/cache

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.