PHPackages                             cjmellor/browser-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. cjmellor/browser-sessions

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

cjmellor/browser-sessions
=========================

A Laravel package to enable users to manage and monitor their active browser sessions. Allows users to view devices where they are logged in and provides options to terminate unrecognized or all sessions, enhancing account security

v2.0.0(1mo ago)27265.4k—8.9%26MITPHPPHP ^8.2CI passing

Since Sep 13Pushed 1w ago1 watchersCompare

[ Source](https://github.com/cjmellor/browser-sessions)[ Packagist](https://packagist.org/packages/cjmellor/browser-sessions)[ Docs](https://github.com/cjmellor/browser-sessions)[ RSS](/packages/cjmellor-browser-sessions/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (9)Dependencies (20)Versions (12)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/25c9e6a3f934aff0c552a5a33a21ef591a1d7e346bb21947166d2a2978ba3da7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636a6d656c6c6f722f62726f777365722d73657373696f6e733f636f6c6f723d7267622532383536253230313839253230323438253239266c6162656c3d72656c65617365267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/cjmellor/browser-sessions)[![Total Downloads](https://camo.githubusercontent.com/a7b6e4842069fdc138e7c2abaf11dc4c3dc01045c8f342a162a512c22e86438c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636a6d656c6c6f722f62726f777365722d73657373696f6e732e7376673f636f6c6f723d7267622532383234392532303131352532303232253239267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/cjmellor/browser-sessions)[![Packagist PHP Version](https://camo.githubusercontent.com/0def399329db41d36afb59c014665f69cf46d1c6d21b1310b89c94707162f032/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f636a6d656c6c6f722f62726f777365722d73657373696f6e732f7068703f636f6c6f723d726762253238313635253230313830253230323532253239266c6f676f3d706870266c6f676f436f6c6f723d726762253238313635253230313830253230323532253239267374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/0def399329db41d36afb59c014665f69cf46d1c6d21b1310b89c94707162f032/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f636a6d656c6c6f722f62726f777365722d73657373696f6e732f7068703f636f6c6f723d726762253238313635253230313830253230323532253239266c6f676f3d706870266c6f676f436f6c6f723d726762253238313635253230313830253230323532253239267374796c653d666f722d7468652d6261646765)[![Laravel Version](https://camo.githubusercontent.com/cb150ae233281b4c32b26d915e5a3d21cf51b04d64709a5d528d6c81df70b1d9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d253545313225374325354531332d7267622832333525323036382532303530293f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/cb150ae233281b4c32b26d915e5a3d21cf51b04d64709a5d528d6c81df70b1d9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d253545313225374325354531332d7267622832333525323036382532303530293f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)

Warning

This package can only be used with the `database` driver for the Sessions. This is how it is done in Jetstream, so keep this in mind as it may turn you off knowing you need to manage sessions in the database.

Logout Other Browser Sessions
=============================

[](#logout-other-browser-sessions)

This package allows you to log out sessions that are active on other devices.

You may find this useful if you have logged in on a different device, or you have let someone else use your account, or you have forgotten to log out of a public computer. It can especially be useful if you see suspicious device activity on your account.

Note

This code has been extracted from [Laravel Jetstream](https://jetstream.laravel.com) and cannot be used outside a Laravel application.

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

[](#installation)

You can install the package via Composer:

```
composer require cjmellor/browser-sessions
```

Publishing the Configuration
----------------------------

[](#publishing-the-configuration)

To publish the configuration file for this package, run the following Artisan command:

```
php artisan vendor:publish --provider="Cjmellor\BrowserSessions\BrowserSessionsServiceProvider"
```

This will copy the `browser-sessions.php` configuration file to your application's config directory, allowing you to customize its settings.

### Configurable Options

[](#configurable-options)

You can customize the following options in the published `config/browser-sessions.php` file:

`include_session_id: (default: false)`

Usage
-----

[](#usage)

### Retrieving A User's Current Sessions

[](#retrieving-a-users-current-sessions)

Use the `BrowserSessions` facade to retrieve all the current user's sessions:

```
BrowserSessions::sessions();
```

This will return an object with some information about each session:

```
[
  {
    "session_id": "2MM6ECkJuUr78mmtA5aPldXSVEfTmOjnSigeP0tg",
    "device": {
      "browser": "Safari",
      "desktop": true,
      "mobile": false,
      "platform": "OS X"
    },
    "ip_address": "127.0.0.1",
    "is_current_device": true,
    "last_active": "1 second ago"
  }
]
```

### Logging Out Other Browser Sessions

[](#logging-out-other-browser-sessions)

Use the `BrowserSessions` facade to log out all the user's other browser sessions:

```
BrowserSessions::logoutOtherBrowserSessions();
```

Note

A `password` must be sent along to the method to confirm the user's identity. Only then will the sessions be removed. See below on how you would implement this.

### Views

[](#views)

The package does not come with any pre-defined views to use. Here is an example though on how this could be implemented

In your `routes/web.php` file add the following route:

```
Route::delete('logout-browser-sessions', function () {
    BrowserSessions::logoutOtherBrowserSessions();

    return back()->with('status', 'Logged out of other browser sessions.');
})->name('logout-browser-sessions');
```

Then in your view, you can add a form to submit a `DELETE` request to the above route:

```

    @csrf
    @method('DELETE')

    Logout Other Sessions

```

Retrieve the Users' Last Activity
---------------------------------

[](#retrieve-the-users-last-activity)

Get the users' last activity by using the `getUserLastActivity` method:

```
BrowserSessions::getUserLastActivity();
```

You can also view the date in a human-readable format:

```
BrowserSessions::getUserLastActivity(human: true);
```

Credits
-------

[](#credits)

- [Chris Mellor](https://github.com/cjmellor)

License
-------

[](#license)

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

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance95

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~122 days

Total

9

Last Release

47d ago

Major Versions

v0.0.1 → v1.0.02023-09-20

v1.3.2 → v2.0.02026-05-18

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/801039?v=4)[cmellor](/maintainers/cmellor)[@cmellor](https://github.com/cmellor)

---

Top Contributors

[![cjmellor](https://avatars.githubusercontent.com/u/1848476?v=4)](https://github.com/cjmellor "cjmellor (38 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![harrisonratcliffe](https://avatars.githubusercontent.com/u/53269265?v=4)](https://github.com/harrisonratcliffe "harrisonratcliffe (6 commits)")[![ataufik135](https://avatars.githubusercontent.com/u/16074652?v=4)](https://github.com/ataufik135 "ataufik135 (1 commits)")[![irabbi360](https://avatars.githubusercontent.com/u/35403788?v=4)](https://github.com/irabbi360 "irabbi360 (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")

---

Tags

laravelbrowser-sessions

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cjmellor-browser-sessions/health.svg)

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M167](/packages/spatie-laravel-health)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

44855.7k](/packages/harris21-laravel-fuse)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1563.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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