ebethus / mongodb-laravel-session
A mongodb session driver for laravel
v0.1.0
2023-07-04 04:29 UTC
Requires
- illuminate/session: ^9.0
- jenssegers/mongodb: ~3.9
This package is auto-updated.
Last update: 2024-11-19 04:48:03 UTC
README
A MongoDB session driver for Laravel
Installation
Install using composer:
composer require 1ff/laravel-mongodb-session
Change the connection in config/session.php
to the name of the mongo connection from your config/database.php
config
'connection' => 'mongodb',
Update your .env file and change the SESSION_DRIVER
to mongodb
SESSION_DRIVER=mongodb
Advantages
- This driver uses the MongoDB TTL indexes meaning when a session key expires it will be automatically deleted. So no need for garbage collection implementation.
- This way, the collection's size will remain around the size you expect and won't get falsely filled with unused data.
- The package automatically adds a migration which creates the index. If you change the name of the
session.table
you should rerun the ttl index creation commandphp artisan mongodb:session:index
.