PHPackages                             jlsalvador/yii-db-http-token-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. jlsalvador/yii-db-http-token-session

ActiveYii-extension[Authentication &amp; Authorization](/categories/authentication)

jlsalvador/yii-db-http-token-session
====================================

YiiDbHttpTokenSession is a Yii extension that extends CDbHttpSession by using a database as a token-session linker for each request-response without the need of a cookie or PHPSESSID usage (like a Rest Api solution).

27PHP

Since Oct 6Pushed 12y ago1 watchersCompare

[ Source](https://github.com/jlsalvador/YiiDbHttpTokenSession)[ Packagist](https://packagist.org/packages/jlsalvador/yii-db-http-token-session)[ RSS](/packages/jlsalvador-yii-db-http-token-session/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

YiiDbHttpTokenSession
=====================

[](#yiidbhttptokensession)

YiiDbHttpTokenSession is a [Yii](http://www.yiiframework.com) extension that extends [CDbHttpSession](http://www.yiiframework.com/doc/api/1.1/CDbHttpSession) by using a database as a token-session linker for each request-response without the need of a cookie or PHPSESSID usage (like a Rest Api solution).

How it works
------------

[](#how-it-works)

The first time that you make a request and your application use a PHP session, a token will be generated and will be echoed in the HTTP header response like `Token: 12345678901234567890123456789012`. Use this token in the next HTTP header request to continue the session, like `Token: 12345678901234567890123456789012`. You can use the HTTP parameter `_t` too (by default). Each request generate a new Token that will be sent to the HTTP header response.

Requirements
------------

[](#requirements)

- PHP 5.3.0 (older versions untested)
- YiiFramework 1.1.13 (older versions untested)

Install
-------

[](#install)

1. Get the source in one of the following ways:

    - [Download](https://github.com/jlsalvador/YiiDbHttpTokenSession/releases) the lasted version and place the files under `protected/extensions/YiiDbHttpTokenSession/` under your application root directory.
    - Add this repository as a git submodule to your repository by calling under your application root directory: `git submodule add https://github.com/jlsalvador/YiiDbHttpTokenSession.git protected/extensions/YiiDbHttpTokenSession`
2. Edit your application configuration and set the session component to YiiDbHttpTokenSession:

```
'components'=>array(
        'session'=>array(
            'class'=>'ext.YiiDbHttpTokenSession',
            'connectionID'=>'db', // Set the database Yii component, it's optional.
            'tokenRequestKeyName'=>'_t', // The $_REQUEST index name that will store a token id instead the HTTP header, defaults to '_t'.
            'tokenHeaderKeyName'=>'HTTP_TOKEN', // The $_SERVER index name that will store a token id, defaults to 'HTTP_TOKEN'.
            'tokenTimeout'=>1440, // The number of seconds after which data will be seen as garbage and cleaned up, defaults to 1440 seconds.
            'tokenTableName'=>'YiiToken', // The token table name, defaults to 'YiiToken'.
            'autoCreateTokenTable'=>true, // Whether the token DB table should be automatically created if not exists, defaults to true.
        ),
),
```

Examples
--------

[](#examples)

JavaScript:

```
var tokenId = '12345678901234567890123456789012'; // Set here your last token id from the HTTP header response.
$.ajax({
    beforeSend: function (xhr) {
        xhr.setRequestHeader('Token', tokenId);
    },
    url:'http://my-site.com/api/work',
    type:'GET',
    success:function(data) {
        console.log(data);
    },
    error:function (xhr, ajaxOptions, thrownError){
        console.log(xhr.responseText);
    }
}).then(function (data, textStatus, xhr) {
    tokenId = xhr.getResponseHeader('Token'); // This set the next token id for the next request.
});
```

CURL:

```
curl -i -H "Accept: application/json" -H "Token: 12345678901234567890123456789012" http://my-site.com/api/work
```

Contributors
------------

[](#contributors)

- [jlsalvador](https://github.com/jlsalvador)

License
-------

[](#license)

YiiDbHttpTokenSession is released under the [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/39f9d5745af2b77e8e8a9473948b951edb78820fae47d8eac8c16e08b7325faa?d=identicon)[jlsalvador](/maintainers/jlsalvador)

---

Top Contributors

[![jlsalvador](https://avatars.githubusercontent.com/u/1464850?v=4)](https://github.com/jlsalvador "jlsalvador (6 commits)")

### Embed Badge

![Health badge](/badges/jlsalvador-yii-db-http-token-session/health.svg)

```
[![Health](https://phpackages.com/badges/jlsalvador-yii-db-http-token-session/health.svg)](https://phpackages.com/packages/jlsalvador-yii-db-http-token-session)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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