Implement logout in the PHP app

This commit is contained in:
Aron Carroll 2012-05-18 14:24:35 +01:00
parent 0aa08cdd34
commit 3e4131e8d7

View File

@ -94,6 +94,18 @@ if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (!$action) {
// do nothing and serve up the page
} else if ($action == 'logout' && $_SERVER['REQUEST_METHOD'] == 'POST') {
unset($_COOKIE['session']);
setcookie('session', null, -1);
$redirect = isset($_POST['_redirect']) ? $_POST['_redirect'] : '/';
if (!$redirect || stripos($redirect, '://') !== false) {
$redirect = '/';
}
header('HTTP/1.1 303 Found');
header('Location: ' . $redirect);
exit;
} else if ($action == 'sethome') {
if ($ajax) {
// 1. encode the key