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

v1.3.2(10mo ago)26752.2k↑11.1%26[2 PRs](https://github.com/cjmellor/browser-sessions/pulls)MITPHPPHP ^8.2CI passing

Since Sep 13Pushed 1mo 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 1mo ago

READMEChangelog (8)Dependencies (10)Versions (10)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/e4311e0cf130f34079ec9753e275d50884bd45a0185f13c6267f00edcdd3cd3b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531302d7267622832333525323036382532303530293f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/e4311e0cf130f34079ec9753e275d50884bd45a0185f13c6267f00edcdd3cd3b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531302d7267622832333525323036382532303530293f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)

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

54

—

FairBetter than 97% of packages

Maintenance74

Regular maintenance activity

Popularity49

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity61

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

Recently: every ~56 days

Total

8

Last Release

329d ago

Major Versions

v0.0.1 → v1.0.02023-09-20

### Community

Maintainers

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

---

Top Contributors

[![cjmellor](https://avatars.githubusercontent.com/u/1848476?v=4)](https://github.com/cjmellor "cjmellor (34 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 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

[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)[pschocke/laravel-telegram-login-widget

Easily integrate Telegrams login widget into your Laravel application to send Telegram messages

1610.4k](/packages/pschocke-laravel-telegram-login-widget)

PHPackages © 2026

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