hrevert/ht-session 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hrevert/ht-session

Composer 安装命令:

composer require hrevert/ht-session

包简介

A Zend Framework 2 module to manage session configurations, session validators, storing session data in database.

README 文档

README

A Zend Framework 2 module to manage session configurations, session validators, storing session data in database.

##Requirements

##Installation

  • Add "hrevert/ht-session": "1.1.*", to your composer.json and run php composer.phar update
  • Enable the module in config/application.config.php
  • Copy file located in ./vendor/hrevert/ht-session/config/HtSession.global.php to ./config/autoload/HtSession.global.php and change the values as you wish

##Options

Check Options available in config/HtSession.global.php

##Features

  • Session configurations
  • Session set save handler
  • Session Validators

Session configurations

You can set all the session options as session name, save path etc.

return [
   'htsession' => [
       'config_options' => array(
              'name' => 'my_application',
              'save_path' => 'data/session'
        ),
        'storage' => 'Zend\Session\Storage\SessionArrayStorage',
     ]
];

Session set save handler

This module also comes with session set save handler to store session data in database. By default session_set_save_hander is already enabled. If you want to disable it, disable it in the following settings:

return [
   'htsession' => [
      'enable_session_set_save_handler' => true, // false if you don`t want to store session data in database
   ],
   'service_manager' => [
      'aliases' => [
         'HtSessionDbAdapter' => 'Zend\Db\Adapter\Adapter', // your database adapter here
         'HtSession\SessionSetSaveHandler' => 'HtSession\DefaultSessionSetSaveHandler'
      ]
   ]
];

Note: Dont forget to import schema available in data/mysql.sql to use session_set_save_handler

If you use Doctrine DBAL:

return [
   'service_manager' => [
      'aliases' => [
         'HtSession\SessionSetSaveHandler' => 'HtSession\DoctrineDbalSessionSetSaveHandler'
      ]
   ]
];

Session Validators

You can set validators provided by Zend Framework 2 with ease. Change the following as you wish in the config file:

return [
   'htsession' => [
       'validators' => array(
           'Zend\Session\Validator\RemoteAddr',
           'Zend\Session\Validator\HttpUserAgent',    
        ),      
   ]
];

For more detailed description, click here.

Ending Thoughts

Dont forget to fork this module and send pull request to make this module even better!

Bitdeli Badge

统计信息

  • 总下载量: 3.04k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 6
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固