AkrabatSession
This ZF2 module is intended to make it simple to change the settings of a
session; specifically the most common change required is to set a name for
the cookie used to hold the session id., (*1)
Installation
You have a number of choices for installing AkrabatSession
:, (*2)
with Composer
Add "akrabat/akrabat-session": "dev-master"
to your composer.json
file and run php composer.phar update
., (*3)
as a Git Submodule
Clone this project into your ./vendor/
directory:, (*4)
git submodule add git://github.com/akrabat/AkrabatSession.git vendor/AkrabatSession
You can also just clone the module into your ./vendor/
directory or download it via the 'Zip' button on github., (*5)
Configuration
Once you have installed AkrabatSession, you need to enable it by editing
config/application.config.php
and adding AkrabatSession
to the modules
section., (*6)
To configure the session as you required, add the following to your
config/autoload/global.php
file:, (*7)
'session' => array(
'name' => 'MY_SESSION_NAME_HERE',
),
Add additional configuration keys as needed., (*8)
Available configuration keys
The available configuration options are in the Zend\Session\Config\SessionConfig
and Zend\Session\Config\StandardConfig
classes. Most map to the PHP level
session directives, (*9)
Some of the more useful ones are:, (*10)
-
name
- Name of the session
-
remember_me_seconds
- Number of seconds to make session sticky, when rememberMe() is called. Default is 2 weeks (1209600 seconds)
-
save_path
- By default, the path where the session files are created
-
cookie_httponly
- Marks the cookie as accessible only through the HTTP protocol.
-
use_only_cookies
- Specifies that only cookies are used and not session ids in URLs
-
cookie_secure
- Specifies that cookies should only be sent over secure connections
Note: AkrabatSession
sets the cookie_httponly
and use_only_cookies
settings to true, (*11)
Session storage and save handler classes
If you need to set the SessionMangers's storage or save handler class, then
simply create a ServiceManager alias of session_storage
or session_save_handler
., (*12)