PHPackages                             ryancco/laravel-sessions - 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. ryancco/laravel-sessions

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

ryancco/laravel-sessions
========================

The missing model for Laravel sessions

0.1(6y ago)03[3 PRs](https://github.com/ryancco/laravel-sessions/pulls)MITPHPPHP ^7.2

Since Apr 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ryancco/laravel-sessions)[ Packagist](https://packagist.org/packages/ryancco/laravel-sessions)[ RSS](/packages/ryancco-laravel-sessions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

Laravel Sessions
================

[](#laravel-sessions)

[![Packagist](https://camo.githubusercontent.com/26012762733aae85d0a7627f04eb1c7faacb03aa5b86164b87765c97df2edfaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7279616e63636f2f6c61726176656c2d73657373696f6e733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/26012762733aae85d0a7627f04eb1c7faacb03aa5b86164b87765c97df2edfaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7279616e63636f2f6c61726176656c2d73657373696f6e733f7374796c653d666c61742d737175617265)[![GitHub Workflow Status](https://camo.githubusercontent.com/42feeea02144d1f6fdb2e94359f61de0f5be457a6c1704575cc2ea8d2e2f7c93/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7279616e63636f2f6c61726176656c2d73657373696f6e732f74657374733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/42feeea02144d1f6fdb2e94359f61de0f5be457a6c1704575cc2ea8d2e2f7c93/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7279616e63636f2f6c61726176656c2d73657373696f6e732f74657374733f7374796c653d666c61742d737175617265)[![Packagist](https://camo.githubusercontent.com/ee3deb6913953311a1b86a651a554b8b149b9146dbebebae85d9ee6bbf7ffc85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7279616e63636f2f6c61726176656c2d73657373696f6e733f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/ee3deb6913953311a1b86a651a554b8b149b9146dbebebae85d9ee6bbf7ffc85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7279616e63636f2f6c61726176656c2d73657373696f6e733f7374796c653d666c61742d737175617265)

The missing model for Laravel sessions with some conveniently opinionated functionality built-in.

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

[](#installation)

Laravel Sessions can be installed via Composer.

```
composer require ryancco/laravel-sessions
```

Usage
-----

[](#usage)

### Apply the HasSessions trait to your User model

[](#apply-the-hassessions-trait-to-your-user-model)

```
class User extends Authenticatable
{
    use \Ryancco\Sessions\HasSessions;
```

### Get a user's active sessions

[](#get-a-users-active-sessions)

`@method active(Carbon|int $last_activity = 60)`

```
$user->sessions()
    ->active(30) // active in the last 30 minutes
    ->get();
```

### Get a user's inactive sessions

[](#get-a-users-inactive-sessions)

`@method inactive(Carbon|int $last_activity = 60)`

```
$user->sessions()->inactive(
    now()->subHours(2) // not active in the last 2 hours
)->get();
```

### Get a session's device

[](#get-a-sessions-device)

Currently, this package leverages [jenssegers/agent](https://github.com/jenssegers/agent) for device information. Check out the pieces used and head over to that repository for any further information.

```
$device = $user->sessions()
    ->latest('last_activity')
    ->first()
    ->device();

$device->device();
$device->browser();
$device->platform();
$device->browserVersion();
$device->platformVersion();
```

Preqrequisites
--------------

[](#preqrequisites)

Laravel Sessions expects you to be using Laravel's database session driver. To learn more about this and other session driver preqrequisites, check out the [documentation](https://laravel.com/docs/master/session#driver-prerequisites).

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

[](#contributing)

Please report any problems by creating an [issue](https://github.com/ryancco/laravel-sessions/issues). Pull requests are always welcomed.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

2205d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e788fd955161ca75bc5d897617be45fc7997dcd1d4e6620af752e4d3acf66943?d=identicon)[ryancco](/maintainers/ryancco)

---

Top Contributors

[![ryancco](https://avatars.githubusercontent.com/u/20148569?v=4)](https://github.com/ryancco "ryancco (3 commits)")

---

Tags

laravelmanagementsession

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ryancco-laravel-sessions/health.svg)

```
[![Health](https://phpackages.com/badges/ryancco-laravel-sessions/health.svg)](https://phpackages.com/packages/ryancco-laravel-sessions)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)[usmanhalalit/laracsv

A Laravel package to easily generate CSV files from Eloquent model.

6151.7M4](/packages/usmanhalalit-laracsv)[hipsterjazzbo/landlord

A simple, single database multi-tenancy solution for Laravel 5.2+

613270.0k1](/packages/hipsterjazzbo-landlord)

PHPackages © 2026

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