Completed
Push — master ( 89b9bc...4042b6 )
by André
102:57 queued 84:06
created

NativeSessionHandler::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 10
rs 9.4285
1
<?php
2
3
/**
4
 * File containing the NativeSessionHandler class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishCoreBundle\Session\Handler;
10
11
/**
12
 * Class NativeSessionHandler.
13
 *
14
 * This class makes it possible to configure the native PHP session handler.
15
 */
16
class NativeSessionHandler extends \SessionHandler
17
{
18
    /**
19
     * @param string $savePath      Path of directory to save session files
20
     *                              Default null will leave setting as defined by PHP.
21
     *                              '/path', 'host:port'
22
     * @param string $saveHandler   Could be any handler supported by php
23
     *                              Default null will leave setting as defined by PHP.
24
     *                              'redis', 'file'
25
     *
26
     * @see http://php.net/manual/en/session.configuration.php#ini.session.save-path for further details.
27
     */
28
    public function __construct($savePath = null, $saveHandler = null)
29
    {
30
        if (null !== $savePath) {
31
            ini_set('session.save_path', $savePath);
32
        }
33
34
        if (null !== $saveHandler) {
35
            ini_set('session.save_handler', $saveHandler);
36
        }
37
    }
38
}
39