PHPackages                             geisi/laravel-db-session-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. geisi/laravel-db-session-helper

ActiveLibrary[Database &amp; ORM](/categories/database)

geisi/laravel-db-session-helper
===============================

This package is build on top of the Laravel session database driver. With it you are able to query users by their login state.

v0.0.2(4y ago)19MITPHPPHP ^7.4|^8.0

Since Aug 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/geisi/laravel-db-session-helper)[ Packagist](https://packagist.org/packages/geisi/laravel-db-session-helper)[ Docs](https://github.com/geisi/laravel-db-session-helper)[ GitHub Sponsors](https://github.com/geisi)[ RSS](/packages/geisi-laravel-db-session-helper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (11)Versions (4)Used By (0)

⚠️ Laravel DB Session Helper is under development - use at your own risk.

Laravel helper package for the database session driver
======================================================

[](#laravel-helper-package-for-the-database-session-driver)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5eb7cb2bfc79ad0a77c0affd27e651995c5795b4eb42d6fe1d4e30dcf04df8e5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67656973692f6c61726176656c2d64622d73657373696f6e2d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/geisi/laravel-db-session-helper)[![GitHub Tests Action Status](https://camo.githubusercontent.com/af565c1cba6f59901120b7754b56a3040e6d6add8ff58c13587f8da568151cea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f67656973692f6c61726176656c2d64622d73657373696f6e2d68656c7065722f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/geisi/laravel-db-session-helper/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5607dd129c8e849ebd2f665339742f85a483d2a290344da137a6243d22eedf56/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f67656973692f6c61726176656c2d64622d73657373696f6e2d68656c7065722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/geisi/laravel-db-session-helper/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/157b3a644f35970f118adda72cdebee3b5fbcce4ca64554a61e14aedcc922fb5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67656973692f6c61726176656c2d64622d73657373696f6e2d68656c7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/geisi/laravel-db-session-helper)

This package adds some niceties when using the database session driver in Laravel Projects. Its main purpose is to be able to filter users by their online state.

It integrates well with Laravel Jetstream applications.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require geisi/laravel-db-session-helper
```

First add HasDatabaseSessions trait to your User model(s):

```
//User.php
use Illuminate\Foundation\Auth\User as Authenticatable;
use Geisi\LaravelDbSessionHelper\Traits\HasDatabaseSessions

class User extends Authenticatable
{
    use HasDatabaseSessions;

    // ...
}
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Geisi\LaravelDbSessionHelper\LaravelDbSessionHelperServiceProvider"
```

Usage
-----

[](#usage)

```
//Query all online users
\App\Models\User::isOnline()->get();
//Query all offline users
\App\Models\User::isOffline()->get();
//Get user online state
var_dump($user->is_online);
// true or false
//Get user last login date
var_dump($user->last_login);
// Carbon instance
```

Requirements
------------

[](#requirements)

To be able to run this package you need Laravel &gt;= 8.42.x and PHP =&gt; 7.4 or PHP 8.0. In order to query the users session data the database session driver is needed.

Configuration
-------------

[](#configuration)

By default the time span to determine if a user is online or offline is 10 minutes. So if a user does not interact with your application within 10 minutes he is gonna be queried as offline.

You can change this timespan with the login\_time\_span configuration value.

You can extend or replace our Session model with your own. The only necessary thing to do is to implement the Geisi\\LaravelDbSessionHelper\\Contracts\\Session contract interface.

Beta
----

[](#beta)

This package is currently in Beta state. As we cannot guarantee 100% stability and feature safety we don't recommend using this package in production. Please submit possible bugs under issues.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Tim Geisendörfer](https://github.com/geisi)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1745d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01edc74b3b6f2ecfe6106f68787500e5c46c51acc7fbe7aa04bb378c9190c79b?d=identicon)[geisi](/maintainers/geisi)

---

Top Contributors

[![geisi](https://avatars.githubusercontent.com/u/10728579?v=4)](https://github.com/geisi "geisi (18 commits)")

---

Tags

databasedrivereloquentlaravellaravel-frameworklaravel-jetstreamloginofflineonlinequerysessionstateuserlaravelgeisilaravel-db-session-helper

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/geisi-laravel-db-session-helper/health.svg)

```
[![Health](https://phpackages.com/badges/geisi-laravel-db-session-helper/health.svg)](https://phpackages.com/packages/geisi-laravel-db-session-helper)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[silber/bouncer

Eloquent roles and abilities.

3.6k4.4M25](/packages/silber-bouncer)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
