| 1 | <?php |
||
| 6 | class GlobalHandler implements SessionHandlerInterface |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * {@inheritdoc} |
||
| 10 | */ |
||
| 11 | 2 | public function destroy($sessionId) |
|
|
|
|||
| 12 | { |
||
| 13 | 2 | $this->bootSession(); |
|
| 14 | 2 | $_SESSION = []; // destroy |
|
| 15 | 2 | @session_destroy(); |
|
| 16 | 2 | return true; |
|
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * {@inheritdoc} |
||
| 21 | */ |
||
| 22 | 2 | public function read($sessionId) |
|
| 30 | |||
| 31 | /** |
||
| 32 | * {@inheritdoc} |
||
| 33 | */ |
||
| 34 | 1 | public function write($sessionId, $sessionData) |
|
| 42 | |||
| 43 | /** |
||
| 44 | * {@inheritdoc} |
||
| 45 | */ |
||
| 46 | public function close() |
||
| 50 | |||
| 51 | /** |
||
| 52 | * {@inheritdoc} |
||
| 53 | */ |
||
| 54 | public function gc($maxLifeTime) |
||
| 58 | |||
| 59 | /** |
||
| 60 | * {@inheritdoc} |
||
| 61 | */ |
||
| 62 | public function open($savePath, $sessionId) |
||
| 66 | |||
| 67 | 3 | protected function bootSession() |
|
| 75 | } |
||
| 76 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: