From 3e4131e8d7205559d656d5f377ff0c0fee3f3fb7 Mon Sep 17 00:00:00 2001 From: Aron Carroll Date: Fri, 18 May 2012 14:24:35 +0100 Subject: [PATCH] Implement logout in the PHP app --- public/app.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/public/app.php b/public/app.php index 6b83a70e..4569b598 100644 --- a/public/app.php +++ b/public/app.php @@ -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