Introducing AkrabatSession zf2
One of the requirements for a new app that I'm writing is that it has a specific session name. In Zend Framework 2, this is done by creating a SessionManager with the correct configuration and then setting the default manager on the Session Container:
use Zend\Session\Config\SessionConfig; use Zend\Session\SessionManager; use Zend\Session\Container; $sessionConfig = new SessionConfig(); $sessionConfig->setOptions(array('name'=>'MY_SESSION_NAME'); $sessionManager = new SessionManager($config); Container::setDefaultManager($sessionManager);
Obviously, I need to be able to configure the name (and potentially other session configuration options) from myconfig/autoload/global.php file and this is a generically useful requirement, so I created the AkrabatSession module.
This is a really simple module that simply allows you to configure the SessionManager with minimal effort:
- Install AkrabatSession.
- Enable it as the first module in application.config.php
- Add the following to your configuration array in global.php:
'session' => array( 'name' => 'MY_SESSION_NAME_HERE', ),
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步