session-storage-abstract This extension contains different storage types where session data can be stored

  1. Requirements
  2. Usage
  3. Resources

Yii 1.1 supports default php session handler (CHttpSession) and SQL database session storage (CDbHttpSession). So, this extension contains and interface that you can use to implement any type of session storage without rewriting of HttpSession component methods. Also you session storage will contain optional extra parameter of session - "userId", so you will be able to distinguish guests' sessions and authenticated users' sessions. Another problems which solves this extension described here (in can be very useful): http://blog.jviba.com/en/web/asynchronous-change-of-session-in-php</a>

Requirements

e.g. Yii 1.1 or above

Usage

  1. Setup imports:
...
'import' => array(
    ...
    'ext.session.*',
    ...
),
...
  1. Change configuration of an application session component:

If you want to use SQL database as storage of sessions:

...
'components' => array(
    'session' => array(
        'class' => 'UserHttpSession',
        'storage' => array(
            'class' => 'SQLSessionStorage',
            'connectionID' => 'db',
        ),
    ),
    ...
    'db' => array(
        'class' => 'CDbConnection',
        ....
    ),
    ...
),
...

If you want to use MongoDb as storage of sessions you should download (http://www.yiiframework.com/extension/yiimongodbsuite"YiiMongoDbSuite extension") and install it into the application.

...
'components' => array(
    'session' => array(
        'class' => 'UserHttpSession',
        'storage' => array(
            'class' => 'MongoSessionStorage',
            'connectionID' => 'mongodb',
        ),
    ),
    ...
    'mongodb' => array(
        'class' => 'EMongoDB',
        'connectionString' => 'mongodb://localhost',
        'dbName' => 'mymongodatabasename',
        'fsyncFlag' => false,
        'safeFlag' => true,
        'useCursor' => false,
        ....
    ),
    ...
),
...

If you want to use Memcache as storage of sessions:

...
'components' => array(
    'session' => array(
        'class' => 'UserHttpSession',
        'storage' => array(
            'class' => 'MemcacheSessionStorage',
            'componentID' => 'memcache',
        ),
    ),
    ...
    'memcache' => array(
        'class' => 'CMemCache',
        ....
    ),
    ...
),
...

If you want to use Redis as storage of sessions you should download (https://github.com/phpnode/YiiRedis"YiiRedis extension") and install it into the application.

...
'components' => array(
    'session' => array(
        'class' => 'UserHttpSession',
        'storage' => array(
            'class' => 'RedisSessionStorage',
            'componentId' => 'redis',
        ),
    ),
    ...
    'redis' => array(
        'class' => 'ARedisConnection',
        ....
    ),
    ...
),
...

Resources

Problems which will solve this extension described here: http://blog.jviba.com/en/web/asynchronous-change-of-session-in-php</a>

0 0
2 followers
326 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Auth
Developed by: djvibegga
Created on: May 26, 2014
Last updated: 10 years ago

Downloads

show all

Related Extensions