alpha-zeta/session

php session library

1.0.1 2024-09-10 12:51 UTC

This package is auto-updated.

Last update: 2024-11-10 13:18:12 UTC


README

php session library

Install

composer require alpha-zeta/session

Usage

config/container.php

return [
    QueryBuilderHandler::class => fn() => (new Connection('mysql', config('database', 'connect.mysql')))->getQueryBuilder(),

    SessionInterface::class => function (QueryBuilderHandler $qb) {
        $handler = match (env('SESSION_DRIVER')) {
            'DB' => new Driver\Db($qb->pdo()),
            default => null,
        };

        return new Session(config('session'), $handler);
    },
];

then see Az\Session\SessionMiddleware class.

And in anywere:

$this->session->foo = 'bar'
$foo = $this->session->foo;

for introduce methods see Az\Session\Session class