PHPackages                             minhbxn/laravel-session-tracker - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. minhbxn/laravel-session-tracker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

minhbxn/laravel-session-tracker
===============================

This package provides session tracking functionalities, multisession management and user device management features for laravel applications.

3.0.0(6y ago)18MITPHPPHP ^7.2

Since Jan 17Pushed 6y agoCompare

[ Source](https://github.com/minhbxn/laravel-session-tracker)[ Packagist](https://packagist.org/packages/minhbxn/laravel-session-tracker)[ RSS](/packages/minhbxn-laravel-session-tracker/feed)WikiDiscussions master Synced yesterday

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

Laravel Session Tracker
=======================

[](#laravel-session-tracker)

This package provides session tracking functionalities, multisession management and user device management features for laravel applications.

Features
--------

[](#features)

- Session Management
- Session Log
- Multiple session for users
- Request Log
- User Devices

Fork Notes
==========

[](#fork-notes)

This repository clones from [hamedmehryar](https://github.com/hamedmehryar/laravel-session-tracker) original repository.

Installation (Laravel 5.x)
--------------------------

[](#installation-laravel-5x)

In composer.json:

```
"require": {
    "hamedmehryar/laravel-session-tracker" "1.0.0"
}

```

Installation (Laravel 6.x)
--------------------------

[](#installation-laravel-6x)

In composer.json:

```
"require": {
    "minhbxn/laravel-session-tracker" "3.0.0"
}

```

Run:

```
composer update

```

Add the service provider to `config/app.php` under `providers`:

```
'providers' => [
    Hamedmehryar\SessionTracker\SessionTrackerServiceProvider::class,
]

```

Add the SessionTracker alias to `config/app.php` under `aliases`:

```
    'aliases' => [
        'SessionTracker' => 'Hamedmehryar\SessionTracker\SessionTrackerFacade',
    ]

```

Update config file to reference your login and logout route names:

```
config/sessionTracker.php

```

Migrate your database:

```
php artisan migrate

```

Add the trait to your user model:

```
use Hamedmehryar\SessionTracker\Traits\SessionTrackerUserTrait;

class User extends Model {
	use SessionTrackerUserTrait;
}

```

Add the DeviceCheck middleware in your kernel.php file:

```
protected $middleware = [
		'Hamedmehryar\SessionTracker\Middleware\DeviceCheck',
	];

```

In Your routes.php file you should add 'session' middleware for routes which you want to keep track of:

```
Route::group(['middleware'=>'session'], function(){

    Route::get('your-route', 'YourController@yourAction');

});

```

Usage
-----

[](#usage)

From your user models:

```
$user->sessions(); //returns all the sessions of the user form the begining of usage of the package

$user->activeSessions(); //returns all currently active sessions for the user. (User may be logged in with same credentials from different devices)

$user->activeSessions(true); //return all active sessions for the user except the current session.

$user->getFreshestSession(); //Returns the most recent session of the user

$user->devices(); //Returns the collection of users saved trusted devices.

$user->devicesUids(); //Returns array of users saved trusted devices Ids.

```

From SessionTrackerFacade:

```
SessionTracker::startSession(); //Creates a new session for current user

SessionTracker::endSession(); //End the current session for the current user

SessionTracker::endSession(true); //End the current session for the current user and forgets the session

SessionTracker::renewSession(); //Restarts the ended session which is not forgotten for the current user. Usefull for restarting the session after locking it for inactivity

SessionTracker::refreshSession($request); //Keeps the session alive for each request. Useful in middleware

SessionTracker::logSession($request); //Logs the current request for the current session. (request logs stored in sessiontracker_session_requests table)

SessionTracker::isSessionInactive(); //Checks if the session is inactive. Determines the inactiveness by subtracting the **delay between last activity and current time** from the **inactivity_seconds** in sessionTracker config file.

SessionTracker::isSessionInactive($user); //Checks if the session for a specific user is inactive. Determines the inactiveness by subtracting the **delay between last activity and current time** from the **inactivity_seconds** in sessionTracker config file.

SessionTracker::blockSession($sessionId); //Blocks (ends and forgets) the current session for the user. (Useful if the user wants to controll all her sessions and block a specific session in a specific location)

SessionTracker::sessionRequests($sessionId); //Returns all requests done by a specific session

SessionTracker::isSessionBlocked(); //Checks if current user does not have an active session

SessionTracker::lockSessionByCode(); //Locks a session by a security code to be unlocked by that code and returns the code. (Usefull for two-step authentication implementation)

SessionTracker::securityCode(); //Returns the security code (hash) for the locked session.

SessionTracker::isSessionLocked(); //Checks if the current session is locked by a security code.

SessionTracker::unlockSessionByCode($code); //Unlocks the locked session by passing the security code. (returns -1 if the code is invalid, -2 if it's expired and 0 if success)

SessionTracker::isUserDevice(); //Returns true if the current device is trusted by the user

SessionTracker::deleteDevice($id); //Deletes a trusted device for the user

SessionTracker::addUserDevice(); //Add the current device as trusted by the user

SessionTracker::forgotSession(); //Checks if the session if forgotten

SessionTracker::sessionId(); //Returns the sessionId for the current session

SessionTracker::deleteSession(); //Deletes and forgets the current session

SessionTracker::refreshSecurityCode(); //Renews the security code by which the current session is locked

```

Author
------

[](#author)

- [Hamed Mehryar](https://github.com/hamedmehryar)
- [MinhBXN](https://github.com/minhbxn)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 76.7% 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 ~591 days

Total

3

Last Release

2219d ago

Major Versions

1.0.0 → 2.0.02020-02-27

2.0.0 → 3.0.02020-04-14

PHP version history (3 changes)1.0.0PHP &gt;=5.4.0

2.0.0PHP &gt;=7.0

3.0.0PHP ^7.2

### Community

Maintainers

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

---

Top Contributors

[![hamed-netlinks](https://avatars.githubusercontent.com/u/17270136?v=4)](https://github.com/hamed-netlinks "hamed-netlinks (33 commits)")[![hamedmehryar](https://avatars.githubusercontent.com/u/6290979?v=4)](https://github.com/hamedmehryar "hamedmehryar (5 commits)")[![minhbxn](https://avatars.githubusercontent.com/u/7065499?v=4)](https://github.com/minhbxn "minhbxn (5 commits)")

---

Tags

support

### Embed Badge

![Health badge](/badges/minhbxn-laravel-session-tracker/health.svg)

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

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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