PHPackages                             ravibpatel/jwt-session - 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. ravibpatel/jwt-session

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

ravibpatel/jwt-session
======================

Easily replace your existing session based authentication with JWT token-based authentication.

v1.0.8(4y ago)76671MITPHPPHP &gt;=7.1CI failing

Since Jun 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ravibpatel/jwt-session)[ Packagist](https://packagist.org/packages/ravibpatel/jwt-session)[ Docs](https://github.com/ravibpatel/JWTSession)[ RSS](/packages/ravibpatel-jwt-session/feed)WikiDiscussions master Synced today

READMEChangelog (9)Dependencies (1)Versions (10)Used By (0)

JWT-SESSION
===========

[](#jwt-session)

Easily replace your existing session based authentication with JWT token-based authentication.

Installation
============

[](#installation)

Use composer to manage your dependencies and download JWT-SESSION:

```
composer require ravibpatel/jwt-session
```

How to use
----------

[](#how-to-use)

Just create the "session.php" file with the following content.

```
require_once __DIR__ . "/vendor/autoload.php";

$JWTSession = new ravibpatel\JWTSession\JWTSession(20, "Your Secret Key");
$JWTSession->setSessionHandler();
```

Now just include "session.php" file instead of using session\_start() as shown below.

session\_start();

```
require_once __DIR__ . "/session.php";
```

Parameters accepted by JWTSession constructor
---------------------------------------------

[](#parameters-accepted-by-jwtsession-constructor)

### 1. Timeout : int

[](#1-timeout--int)

Session timeout in minutes.

### 2. Secret Key : string

[](#2-secret-key--string)

This will be used to sign your session cookie.

### 3. Expire on Browser Close : boolean

[](#3-expire-on-browser-close--boolean)

Set it to true if you want the session to expire when the user closes the browser otherwise set it to false. By default, it is set to false.

### 4. Cookie name : string

[](#4-cookie-name--string)

If you are running multiple websites using this library on same domain then it is a good idea to set this to something else to avoid session collision. By default, it is set to "AUTH\_BEARER".

### 5. Domain : string

[](#5-domain--string)

By default it will be set to $\_SERVER\["HTTP\_HOST"\]. You can set it manually to point to your domain. The session cookie will only work for Domain you set here.

Note
----

[](#note)

The JWT Token can't be tampered with, but it is readable. This library stores the JWT token into a cookie so it is recommended that you don't save sensitive data like passwords in it. Also, the cookie can store only 4093 bytes of data so you should not store lots of information in your session.

Motivation
----------

[](#motivation)

- [JSON Web Tokens (JWT) vs Sessions](https://float-middle.com/json-web-tokens-jwt-vs-sessions/)
- [byjg/jwt-session](https://github.com/byjg/jwt-session)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Recently: every ~13 days

Total

9

Last Release

1504d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v1.0.4PHP &gt;=7.1

### Community

Maintainers

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

---

Top Contributors

[![ravibpatel](https://avatars.githubusercontent.com/u/2221060?v=4)](https://github.com/ravibpatel "ravibpatel (9 commits)")

---

Tags

jwtAuthenticationtokensession save handler

### Embed Badge

![Health badge](/badges/ravibpatel-jwt-session/health.svg)

```
[![Health](https://phpackages.com/badges/ravibpatel-jwt-session/health.svg)](https://phpackages.com/packages/ravibpatel-jwt-session)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k294.2M219](/packages/google-auth)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[bizley/jwt

JWT integration for Yii 2

69478.8k2](/packages/bizley-jwt)[tuupola/branca

Authenticated and encrypted API tokens using modern crypto.

52330.8k1](/packages/tuupola-branca)[dev-toolbelt/jwt-token-manager

Framework-agnostic JWT token manager with RSA/HMAC support

111.3k](/packages/dev-toolbelt-jwt-token-manager)[internacionalweb/cognito-token-verifier

This library verifies that the signature of the JWT is valid, comes from a desired application, and that the token has not been tampered with or expired.

102.4k](/packages/internacionalweb-cognito-token-verifier)

PHPackages © 2026

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