app/library/Services.php: update session initialization
This commit is contained in:
parent
2dd571cd3d
commit
771cb05b12
1 changed files with 8 additions and 11 deletions
|
|
@ -18,7 +18,6 @@ use Phalcon\Di\FactoryDefault as DiDefault,
|
||||||
Phalcon\Translate\Adapter\NativeArray as TranslateAdapter,
|
Phalcon\Translate\Adapter\NativeArray as TranslateAdapter,
|
||||||
Phalcon\Logger,
|
Phalcon\Logger,
|
||||||
Phalcon\Logger\Adapter\File as FileLogAdapter,
|
Phalcon\Logger\Adapter\File as FileLogAdapter,
|
||||||
Phalcon\Session\Adapter\Files as SessionAdapter,
|
|
||||||
Phalcon\Mvc\Router;
|
Phalcon\Mvc\Router;
|
||||||
|
|
||||||
use Httpcb\Auth,
|
use Httpcb\Auth,
|
||||||
|
|
@ -190,25 +189,23 @@ class Services extends DiDefault
|
||||||
protected function _initSession()
|
protected function _initSession()
|
||||||
{
|
{
|
||||||
$config = $this->get('config');
|
$config = $this->get('config');
|
||||||
|
$session = new \Phalcon\Session\Manager();
|
||||||
|
|
||||||
if (isset($config->session)) {
|
if (isset($config->session)) {
|
||||||
$data = $config->session->toArray();
|
$data = $config->session->toArray();
|
||||||
$adapter = isset($data['adapter']) ? $data['adapter'] : 'Files';
|
$adapter_name = isset($data['adapter']) ? $data['adapter'] : 'Stream';
|
||||||
$options = $data['options'];
|
$options = $data['options'];
|
||||||
|
|
||||||
// For "Files": Set session path if defined.
|
$class = 'Phalcon\Session\Adapter\\' . $adapter_name;
|
||||||
if ($adapter === 'Files' && isset($options['path'])) {
|
$adapter = new $class($options);
|
||||||
session_save_path($config->application->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$class = 'Phalcon\Session\Adapter\\' . $adapter;
|
|
||||||
$session = new $class($options);
|
|
||||||
}
|
}
|
||||||
// Default to File storage
|
// Default to Stream
|
||||||
else {
|
else {
|
||||||
$session = new \Phalcon\Session\Adapter\Files();
|
$adapter = new \Phalcon\Session\Adapter\Stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$session->setAdapter($adapter);
|
||||||
|
|
||||||
// Start session.
|
// Start session.
|
||||||
$session->start();
|
$session->start();
|
||||||
return $session;
|
return $session;
|
||||||
|
|
|
||||||
Reference in a new issue