forked from BeauCal/beaucal-invalid-session
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
35 lines (27 loc) · 825 Bytes
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace BeaucalInvalidSession;
use Zend\Mvc\MvcEvent;
use Zend\Session\AbstractManager;
class Module {
public function getConfig() {
return include __DIR__ . '/config/module.config.php';
}
public function onBootstrap(MvcEvent $e) {
$sessionManager = $e->getApplication()->getServiceManager()
->get('Zend\Session\SessionManager');
$this->forgetInvalidSession($sessionManager);
}
protected function forgetInvalidSession(AbstractManager $sessionManager) {
try {
$sessionManager->start();
return;
} catch (\Exception $e) {
}
/**
* Session validation failed: toast it and carry on.
*/
// @codeCoverageIgnoreStart
session_unset();
// @codeCoverageIgnoreEnd
}
}