hrevert / ht-session
A Zend Framework 2 module to manage session configurations, session validators, storing session data in database.
Installs: 3 038
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 7
Forks: 7
Open Issues: 2
Requires
- php: >=5.4
- zendframework/zend-modulemanager: ~2.2
- zendframework/zend-mvc: ~2.2
- zendframework/zend-session: ~2.2
- zendframework/zend-stdlib: ~2.2
Suggests
- zendframework/zend-db: To store session in database
This package is auto-updated.
Last update: 2024-12-13 03:47:45 UTC
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 runphp 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!