Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Mongodb Session

Mongodb Session Laravel Package

jenssegers/mongodb-session

MongoDB session driver for Laravel. Store user sessions in MongoDB instead of files or databases, using Laravel’s session API. Ideal for distributed apps that need scalable, persistent session storage alongside jenssegers/laravel-mongodb.

View on GitHub
Deep Wiki
Context7

A MongoDB session driver for Laravel 4, 5, 6, 7 and 8

Frequently asked questions about Mongodb Session
How do I install and configure jenssegers/mongodb-session in Laravel?
Install it with Composer alongside ext-mongodb and jenssegers/laravel-mongodb, then set the session driver to mongodb and define the connection and collection in config/session.php. A competent Laravel engineer can complete a happy-path proof in an afternoon, but plan separate time for concurrency and failover testing. The package integrates through Laravel's session manager and Session::extend(), so the Session facade and middleware keep working unchanged.
Which Laravel and PHP versions does jenssegers/mongodb-session support?
The declared support stops at Laravel 8 and PHP 7.x, and Laravel 8 security support ended in January 2023. Any application on Laravel 9 or newer is not an addressable target for this package. For modern Laravel versions you need a maintained fork or a different session storage approach.
Is jenssegers/mongodb-session still actively maintained?
The assessment describes it as effectively a personal utility with zero dependents and low community signal. Check the last commit, last release, open-issue backlog, and CI matrix before adopting it. It is published and has a credible maintainer, but that is not the same as actively maintained.
Does jenssegers/mongodb-session require jenssegers/laravel-mongodb?
Yes, it works with MongoDB connections and the jenssegers/laravel-mongodb ecosystem. That dependency chain is deprecated and superseded by MongoDB-maintained mongodb/laravel-mongodb v4 and later. Adopting this package therefore pins you to an ancestor of the currently supported library.
Does the MongoDB session driver support session locking for concurrent requests?
The assessment finds no session locking or atomic-update strategy, so concurrent requests from one browser race on read-modify-write of the session document. The result is not a clean error but intermittent lost flash data, dropped cart mutations, or surprise logouts. You must treat it as last-write-wins and design around that risk.
What are the production risks of storing Laravel sessions in MongoDB with this driver?
Consistency semantics are caller-owned: you must set read preference to primary and write concern to majority and journaled, or you can ship random logouts under failover. Collection growth, failover handling, and concurrency behaviour are not exercised by a happy-path spike. Plan days, not hours, for the hardening and test matrix.
How does jenssegers/mongodb-session handle session lifetime and garbage collection?
It supports Laravel's standard session API and garbage collection and lets you configure the connection, collection, and session lifetime. It relies on Laravel's session.lottery for probabilistic cleanup. Verify how the handler interacts with lottery and whether the collection has appropriate indexes and TTL settings in your deployment.
Does this package work with Auth::logoutOtherDevices and session invalidation?
That depends on whether the handler implements SessionUpdateTimestampHandlerInterface, including validateId and updateTimestamp, and whether it supports user_id-based invalidation. The assessment flags handler contract completeness as a key question, not a confirmed behaviour. Verify it before relying on Auth::logoutOtherDevices or Laravel session blocking.
Is the MongoDB session handler already included in laravel-mongodb, making this package redundant?
The session handler has historically also shipped inside the main laravel-mongodb package, which may make this a legacy artefact. Check your installed mongodb/laravel-mongodb version before writing any code. If the capability is already present, the decision changes from adopt to we already have it.
What alternatives should I consider instead of jenssegers/mongodb-session?
If you need Laravel 9 or newer, use a modern maintained package such as mongodb/laravel-mongodb or a supported fork, or stick with Redis or a relational database session table. Choose the MongoDB driver only if MongoDB is already a tier-0 or tier-1 datastore in your estate. Otherwise it adds a second stateful dependency for a very small workload.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections