sebdesign / laravel-stack-session-handler
Stack multiple session handlers for Laravel
Requires
- php: ^7.2
- illuminate/session: ^6.0
Requires (Dev)
- nunomaduro/larastan: ^0.4.3
- nunomaduro/phpinsights: ^1.9
- orchestra/testbench: ^4.2
- phpunit/phpunit: ^8.2
- symfony/var-dumper: ^4.3
This package is auto-updated.
Last update: 2024-10-24 05:02:42 UTC
README
A session handler that stacks multiple session handlers in Laravel's session store. The session data will be read from the first handler in the stack if possible, and will be written to all handlers.
Installation
You can install the package via composer:
composer require sebdesign/laravel-stack-session-handler
Usage
In your .env
set the SESSION_DRIVER
to stack
.
SESSION_DRIVER=stack
Then in your config/session.php
add a drivers
array with the drivers you want to stack.
'drivers' => ['redis', 'database'],
Note that the order of drivers is important when starting the session: the first handler will be used to read the session data, and if there is no data it will read from the second handler, etc.
When the session is saved, it will be written to all the handlers, the order is not important in that case.
E.g. We can use redis
to read sessions efficiently, and also database
to be able to query the sessions.
If you forget to set the drivers
array, the file
driver will be used.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@sebdesign.eu instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.