PHPackages                             amuzcorp/laravel-custom-session-handler - 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. amuzcorp/laravel-custom-session-handler

ActiveLibrary

amuzcorp/laravel-custom-session-handler
=======================================

Custom session handler for Laravel that allows excluding last\_activity updates

1.0.5(1y ago)032MITPHPPHP &gt;=8.2

Since Apr 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/amuzcorp/laravel-custom-session-handler)[ Packagist](https://packagist.org/packages/amuzcorp/laravel-custom-session-handler)[ RSS](/packages/amuzcorp-laravel-custom-session-handler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Laravel Custom Session Handler
==============================

[](#laravel-custom-session-handler)

[![Latest Stable Version](https://camo.githubusercontent.com/9a5cbcf1d8f2a8a69f3feb08153071bbd673f7287625bcc14c625a6c1c499c3e/68747470733a2f2f706f7365722e707567782e6f72672f616d757a636f72702f6c61726176656c2d637573746f6d2d73657373696f6e2d68616e646c65722f76)](https://packagist.org/packages/amuzcorp/laravel-custom-session-handler)[![License](https://camo.githubusercontent.com/262520faffb914d238bc0640974a6a4862d44243da6fef4ee25d0b12913be851/68747470733a2f2f706f7365722e707567782e6f72672f616d757a636f72702f6c61726176656c2d637573746f6d2d73657373696f6e2d68616e646c65722f6c6963656e7365)](https://packagist.org/packages/amuzcorp/laravel-custom-session-handler)

Laravel의 기본 Database Session 드라이버를 확장하여
**특정 라우트나 조건에 따라 `last_activity` 컬럼 업데이트를 제외할 수 있는 세션 핸들러**입니다.

---

✨ 주요 기능
-------

[](#-주요-기능)

- `SESSION_DRIVER=custom_database`로 간단히 사용 가능
- `request()->routeIs()` 기반으로 제외할 라우트 설정
- 사용자가 직접 `callback`을 등록해 제외 조건 제어 가능
- Laravel 9, 10, 11, 12 호환

---

💾 설치
----

[](#-설치)

```
composer require amuzcorp/laravel-custom-session-handler
```

---

⚙️ 설정
-----

[](#️-설정)

### 1. `.env`

[](#1-env)

```
SESSION_DRIVER=custom_database
```

### 2. `config/session.php`

[](#2-configsessionphp)

확인만 하면 됩니다. (`SESSION_DRIVER` 값을 가져오기 때문에 수정 불필요)

### 3. 설정 파일 퍼블리시 (선택사항)

[](#3-설정-파일-퍼블리시-선택사항)

필요한 경우 다음 명령어로 설정 파일을 퍼블리시할 수 있습니다:

```
php artisan vendor:publish --provider="Amuz\CustomSession\CustomSessionServiceProvider" --tag=config
```

---

🧩 자동 등록되는 Service Provider
--------------------------

[](#-자동-등록되는-service-provider)

패키지는 `CustomSessionServiceProvider`를 자동으로 등록합니다.
서비스 프로바이더 내에서 커스텀 세션 핸들러가 다음과 같이 동작합니다:

```
Session::extend('custom_database', function ($app) {
    $handler = new CustomDatabaseSessionHandler(
        DB::connection(config('session.connection')),
        config('session.table'),
        config('session.lifetime'),
        $app
    );

    // route 이름 기반으로 제외
    $handler->excludeRoutes([
        'health.check',
        'api.metrics',
    ]);

    // callback 기반으로 제외
    $handler->addExclusionCallback(function ($request) {
        return str_contains($request->userAgent(), 'HealthChecker');
    });

    return $handler;
});
```

---

✅ 예시: routes/web.php
--------------------

[](#-예시-routeswebphp)

```
use Illuminate\Support\Facades\Route;

Route::get('/health', function () {
    return response()->json(['status' => 'ok']);
})->name('health.check');

Route::get('/dashboard', function () {
    session(['visited' => now()]); // 세션이 업데이트되어야 함
    return view('dashboard');
});
```

---

🧪 작동 방식
-------

[](#-작동-방식)

- `CustomDatabaseSessionHandler::write()`에서 `request()->routeIs()` 또는 등록된 콜백에 따라 `last_activity` 업데이트 여부 결정
- 제외 조건을 만족하면 `last_activity` 컬럼은 변경되지 않음
- 나머지 Laravel 세션 기능은 그대로 유지됨

---

📦 composer.json 참고
------------------

[](#-composerjson-참고)

```
"extra": {
  "laravel": {
    "providers": [
      "Amuzcorp\\CustomSession\\CustomSessionServiceProvider"
    ]
  }
}
```

---

🔐 보안 및 버전 정책
------------

[](#-보안-및-버전-정책)

- Laravel 공식 `DatabaseSessionHandler`를 그대로 상속하므로 보안 및 세션 구조는 동일
- 버전은 Semantic Versioning(semver)을 따릅니다: `MAJOR.MINOR.PATCH`

---

🪪 라이선스
------

[](#-라이선스)

MIT License. 자유롭게 사용, 수정, 재배포 가능합니다.

---

✋ 기여하기
------

[](#-기여하기)

- PR / Issue 환영합니다
- 라우트 패턴 정규식 지원, exclude by middleware 등 확장 아이디어도 환영합니다!

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance49

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

3

Last Release

401d ago

### Community

Maintainers

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

---

Top Contributors

[![zerogon1203](https://avatars.githubusercontent.com/u/107824746?v=4)](https://github.com/zerogon1203 "zerogon1203 (11 commits)")

### Embed Badge

![Health badge](/badges/amuzcorp-laravel-custom-session-handler/health.svg)

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

PHPackages © 2026

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