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 ¶
- Setup imports:
...
'import' => array(
...
'ext.session.*',
...
),
...
- 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>
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.