Conditions | 7 |
Paths | 11 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
41 | public function getSessionHandler() |
||
42 | { |
||
43 | $driver = config()->get('session_driver'); |
||
44 | |||
45 | if (!session_id()) { |
||
46 | |||
47 | if ($driver == $this->databaseDriver) { |
||
48 | $orm = (new Database(new Loader()))->getORM(config()->get('session_table', 'sessions')); |
||
49 | session_set_save_handler(new DbSessionHandler($orm), true); |
||
50 | } |
||
51 | |||
52 | if (@session_start() === false) { |
||
53 | throw new \RuntimeException(ExceptionMessages::RUNTIME_SESSION_START); |
||
54 | } |
||
55 | } |
||
56 | |||
57 | if (isset($_SESSION['LAST_ACTIVITY']) && time() - $_SESSION['LAST_ACTIVITY'] > config()->get('session_timeout', 1800)) { |
||
58 | if (@session_destroy() === false) { |
||
59 | throw new \RuntimeException(ExceptionMessages::RUNTIME_SESSION_DESTROY); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | $_SESSION['LAST_ACTIVITY'] = time(); |
||
64 | |||
65 | return new Session($_SESSION, new Cryptor); |
||
66 | } |
||
69 |