123456789101112131415161718192021222324252627 |
- <?php
- require_once "{$_SERVER['DOCUMENT_ROOT']}/dependencies.php";
- use Respect\Validation\Validator as v;
- // only requre POST ['action' => 'desconectar' | 'sign-out']
- methods([
- 'POST' => v::keySet(
- v::key('action', v::stringType()->notEmpty()->in(['desconectar', 'sign-out']))
- ), 'GET' => v::alwaysValid()
- ]);
- if ($_SERVER['REQUEST_METHOD'] === 'GET') {
- session_destroy();
- } else
- switch ($_POST['action']) {
- case 'desconectar':
- unset($_SESSION['page']);
- unset($_SESSION['moodle_db']);
- break;
- case 'sign-out':
- session_destroy();
- break;
- }
- header('Location: /');
|