app/library/Services.php: add config for session.
This commit is contained in:
parent
aa07255891
commit
a2ea4f54e0
1 changed files with 16 additions and 6 deletions
|
|
@ -187,15 +187,25 @@ class Services extends DiDefault
|
|||
{
|
||||
$config = $this->get('config');
|
||||
|
||||
// Set session directory if defined.
|
||||
if (isset($config->application->sessionDir)) {
|
||||
session_save_path($config->application->sessionDir);
|
||||
if (isset($config->session)) {
|
||||
$data = $config->session->toArray();
|
||||
$adapter = $data['adapter'];
|
||||
$options = $data['options'];
|
||||
|
||||
$class = 'Phalcon\Session\Adapter\\' . $adapter;
|
||||
$session = new $class($options);
|
||||
}
|
||||
// Default to File storage
|
||||
else {
|
||||
// Set session directory if defined.
|
||||
if (isset($config->application->sessionDir)) {
|
||||
session_save_path($config->application->sessionDir);
|
||||
}
|
||||
$session = new SessionAdapter();
|
||||
}
|
||||
|
||||
// Create and start session.
|
||||
$session = new SessionAdapter();
|
||||
// Start session.
|
||||
$session->start();
|
||||
|
||||
return $session;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue